0

I want to convert my database in postgresql to sqlite3 during upgrading my software

  • 1
    Possible duplicate of [How to convert a postgres database to sqlite](http://stackoverflow.com/questions/6148421/how-to-convert-a-postgres-database-to-sqlite) – Elad Mar 08 '16 at 07:41

2 Answers2

0

Normally you do the oposite. If it is small, you take the metadata of each table, copy paste to the gui of sqlite and just change the differents datatype. Programmatically you prepare a list of "INSERT INTO bla bla" one for each row. If you use.net system use stringbuilder to compose the strings. The query must be sorted for the autoincrement value. Than run them. Small tip activate PRAGMA synchronous = OFF in sqlite if you have to insert a huge ammount of rows. Remember to format the data.

jurhas
  • 613
  • 1
  • 4
  • 12
0

Another solution is prepare a sqlquery:

SELECT 'INSERT INTO tbl_name VALUES(' || v1 || ',' || v2 || ')' 
FROM tbl_name ORDER BY v1 --if is autoincrement

then copy-paste and enjoy

jurhas
  • 613
  • 1
  • 4
  • 12