how to import data from postgres database to android sqlite

0

Issue

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.

Solution

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

Answered By – varnothing

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave A Reply

Your email address will not be published.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More