2015-05-20 125 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

相關問題