1

I need to convert a postgres file into sqlite3 database file. I already have data in popstgres db. This is related to Django-webapp. Is it possible and if yes, how?

Giles Thomas
  • 6,039
  • 2
  • 33
  • 51

2 Answers2

0

First you need to make dump of current postgresql db. Either use pgAdmin (right click and backup) or pg_dump.

pg_dump --data-only --inserts YOUR_DB_NAME > dump.sql'

There could be possible also some modification, check convert pqsql to sqlite3

Remove the lines starting with SET

Remove the lines starting with SELECT pg_catalog.setval

Replace true for ‘t’

Replace false for ‘f’

in sqlite3

sqlite3 database_name
sqlite> .read 'path_to_dump.sql'
Community
  • 1
  • 1
Coolman
  • 166
  • 3
  • 11
  • 1
    Hi, thanks a lot. I am half way! created the dump.sql from pgadmin (selected data only and blobs-yes). WHile reading in sqlite3, it is showing syntax error: Error: near line 16: near "COPY": syntax error Error: near line 17: unrecognized token: "\" I seelines in the dump.sql as: COPY public ....... FROM stdin; \. Any ideas? Thanks though for a headstart!! – Tejaswi Nisanth Mar 08 '20 at 20:23
0

This is where I found my answer, as my problem was related to databases and django --> here.