Hi, Try the script at the link to migrate the database. You should be able to dump the SQLite database and import it into the Postgres database outside of web2py. I have not tested this script, other have used it successfully.
https://gist.github.com/eclubb/2253099 Thanks! Andy On Friday, April 25, 2014 6:29:12 AM UTC-4, Michele Comitini wrote: > > Use this: > http://pgloader.org/howto/pgloader.1.html > > > > > 2014-04-24 14:39 GMT+02:00 Rene Dohmen <[email protected] <javascript:>>: > >> Hi Web2py users, >> >> we are struggling, for some time now, with a migration of our apps from >> sqlite to postgres. We tried a couple of approaches: first we tried doing >> it with cp_db.py but that had problems with relations and seems broken. Our >> current approach consist of these steps: >> >> 1) export data with: >> def export_all(): >> db.export_to_csv_file(open('export_all.csv', 'w')) >> >> 2) change conenction string from sqlite: >> db = DAL('sqlite://storage.sqlite', migrate=settings.migrate) >> TO: >> db = DAL('postgres://user:pass@localhost/project', migrate=settings. >> migrate, check_reserved=False, entity_quoting=True) >> >> 3) remove contents of database/ folder and let web2py create the DB >> >> 4) import data from the csv >> def import_all(): >> db.import_from_csv_file(open('export_all.csv', 'r')) >> >> >> The import then runs for a very long time and after 10 minutes or so a >> ticket is served: >> ----- >> Ticket ID >> >> 127.0.0.1.2014-04-24.13-38-52.6c7d2674-34e2-4968-9526-ee78b83fda76 >> Versie web2py™Version 2.9.5-stable+timestamp.2014.03.16.02.35.39PythonPython >> 2.7.5: /usr/bin/python (prefix: >> /System/Library/Frameworks/Python.framework/Versions/2.7) Traceback >> >> 1. >> 2. >> 3. >> 4. >> 5. >> 6. >> 7. >> 8. >> 9. >> 10. >> 11. >> 12. >> 13. >> 14. >> 15. >> 16. >> 17. >> 18. >> 19. >> 20. >> 21. >> 22. >> 23. >> 24. >> 25. >> 26. >> 27. >> >> Traceback (most recent call last): >> File "/Users/acidjunk/GIT/formatics.web2py/gluon/main.py", line 539, in >> wsgibase >> >> BaseAdapter.close_all_instances('rollback') >> File "/Users/acidjunk/GIT/formatics.web2py/gluon/dal.py", line 600, in >> close_all_instances >> >> db._adapter.close(action) >> File "/Users/acidjunk/GIT/formatics.web2py/gluon/dal.py", line 580, in >> close >> >> getattr(self, action)() >> File "/Users/acidjunk/GIT/formatics.web2py/gluon/dal.py", line 1923, in >> rollback >> >> return self.connection.rollback() >> File "/Users/acidjunk/GIT/formatics.web2py/gluon/contrib/pg8000/dbapi.py", >> line 455, in _fn >> >> return fn(self, *args, **kwargs) >> >> File "/Users/acidjunk/GIT/formatics.web2py/gluon/contrib/pg8000/dbapi.py", >> line 551, in rollback >> >> self.conn.rollback() >> File >> "/Users/acidjunk/GIT/formatics.web2py/gluon/contrib/pg8000/interface.py", >> line 622, in rollback >> >> self._rollback.execute() >> File >> "/Users/acidjunk/GIT/formatics.web2py/gluon/contrib/pg8000/interface.py", >> line 166, in execute >> >> self.c.close_portal(self._portal_name) >> >> File >> "/Users/acidjunk/GIT/formatics.web2py/gluon/contrib/pg8000/protocol.py", >> line 1326, in close_portal >> >> reader.handle_messages() >> File >> "/Users/acidjunk/GIT/formatics.web2py/gluon/contrib/pg8000/protocol.py", >> line 906, in handle_messages >> >> msg = self._conn._read_message() >> >> File >> "/Users/acidjunk/GIT/formatics.web2py/gluon/contrib/pg8000/protocol.py", >> line 1033, in _read_message >> >> bytes = self._read_bytes(5) >> >> File >> "/Users/acidjunk/GIT/formatics.web2py/gluon/contrib/pg8000/protocol.py", >> line 1021, in _read_bytes >> >> self._sock_buf = self._sock.recv(1024) >> timeout: timed out >> >> Error snapshot [image: >> help]<http://localhost:9999/admin/default/ticket/leondewit/127.0.0.1.2014-04-24.13-38-52.6c7d2674-34e2-4968-9526-ee78b83fda76#> >> >> >> <class 'socket.timeout'>(timed out) >> ----- >> >> Is there a better way to do this kind of migrate, or to have better debug >> info about where it goes wrong? >> >> Any help is appreciated. >> >> Kind Regards >> >> Rene >> >> -- >> Resources: >> - http://web2py.com >> - http://web2py.com/book (Documentation) >> - http://github.com/web2py/web2py (Source code) >> - https://code.google.com/p/web2py/issues/list (Report Issues) >> --- >> You received this message because you are subscribed to the Google Groups >> "web2py-users" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected] <javascript:>. >> For more options, visit https://groups.google.com/d/optout. >> > > -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.

