2015-05-20 124 views
0

我有一个Postgres数据库服务器,我需要将表格记录从postgres下载到平板电脑android(sqlite数据库)。 Android中有这样的功能吗?如何将数据从postgres数据库导入到android sqlite

示例:在postgres中有一个客户表,我需要将此表导入到android中的sqlite。

欢迎任何提示。

此致敬礼。

+0

感谢您的修复Bidhan – Fabricio

回答

2

这可以通过在sql文件中从postgres中将数据库弄糟并将其导入到sqlite来完成。

将数据库转储到sql文件中。

pg_dump dbname > outfile.sql 

参考:从SQL转储文件http://www.postgresql.org/docs/9.1/static/backup-dump.html

导入数据库

sqlite> .read outfile.sql 

编号:https://www.sqlite.org/cli.html

你可以转储使用Postgres的特定表以下命令:

pg_dump --table=table dbname > outfile.sql 
+0

这是一个有效的答案,但如果记录存在,我需要更新数据库。 – Fabricio

+0

你可以在mysql转储文件中用'INSERT OR REPLACE'替代 'INSERT INTO'。 http://stackoverflow.com/questions/418898/sqlite-upsert-not-insert-or-replace – electropoet

相关问题