0

I have a Postgres database server and I need to download the table records from postgres to tablet android (sqlite database). Is there a feature in Android to do this?

Example: There is a customer table in postgres and i need to import this table to sqlite in android.

Any tips are welcome.

Best regards.

Bidhan
  • 10,089
  • 3
  • 34
  • 46
Fabricio
  • 306
  • 4
  • 18

1 Answers1

3

This can be done by dumbing database in sql file from postgres and importing it to sqlite.

Dump database in a sql file.

pg_dump dbname > outfile.sql

Ref: http://www.postgresql.org/docs/9.1/static/backup-dump.html

Import database from sql dump file

sqlite> .read outfile.sql

Ref: https://www.sqlite.org/cli.html

You can dump specific table in postgres using following command:

pg_dump  --table=table dbname > outfile.sql
varnothing
  • 1,111
  • 1
  • 16
  • 28
  • That is a valid answer, but i need update the database if the record exists. – Fabricio May 20 '15 at 16:12
  • you can replace `INSERT INTO` with `INSERT OR REPLACE` in mysql dump file. http://stackoverflow.com/questions/418898/sqlite-upsert-not-insert-or-replace – varnothing May 22 '15 at 10:34