Hi eveyone, Just one clarification. When I said "I do not really know why, but some of the tables did not make it into the new db." in my previous email, I meant that some table data (as a whole) did not make it into the new db.
This meaning the table is there but none of the original data (not a record) is in the db. Even if the data was correctly export to the .csv file. Surprinsingly when a new record is inserted in any of the tables presenting this problem, the id will start as if previous data had been correctly loaded (e.g. if N record were in the original SQLite table, the new will get N+1 id). Regards, Jon. <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail> Libre de virus. www.avast.com <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail> <#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2> On Thu, Feb 7, 2019 at 1:05 PM Jon Subscripted <jonsubscripti...@gmail.com> wrote: > Hi everyone, > Eventually I managed to move on, without cpdb.py. > > I had to do it as Massimo suggests in this thread "Best way to migrate > from sqlite to postgresql (or other db)": > > https://groups.google.com/forum/#!topic/web2py/mQk2hoRf7gw > > Eventhough, auth tables game me a lot of issues and had to tweak the > processs a little. I followed the steps below: > > 1) Launched my old app from command line: > >>> python web2py.py -S old_sqlite_based_app -M -P > 2) Export the db to a single .csv file: > >>> db.export_to_csv_file(open('backup.csv','wb')) > 3) Create new empty app with SQLite > 4) Create empty db (schema only, no tables) in mysql > 5) Change db uri to mysql empty db > 6) Launch app from command line to get models built (mainly auth tables): > >>> python web2py.py -S new_empty_app -M -P > 7) Stop it and check auth tables were built in mysql correctly > 8) Clone my old app code with Mercurial in the new app folder > 9) Launch app from command line to get models built (all remaining tables, > except auth which were already built) > 10) Stop it and check all remaining tables were built in mysql correctly > 11) Launch app from command line and load .csv file data > >>> db.import_from_csv_file(open('backup.csv','rb')) > > I do not really know why, but some of the tables did not make it into the > new db. > > I'm pretty happy with the result anyway. > Regards, Jon. > > PS. When I was doing the process as orginally suggested by Massimo and > Michael Beller (without steps 3,5,6 and 6) I got the error below. Which I > do not understand, but led me to create the empty db to get some fresh auth > tables. > I just wonder if there's some kind of problem in my original tables... > > C:\Users\Jon\Downloads\web2py_src\web2py>python web2py.py -S old_app -M -P > web2py Web Framework > Created by Massimo Di Pierro, Copyright 2007-2019 > Version 2.17.2-stable+timestamp.2018.10.06.18.54.02 > Database drivers available: sqlite3, imaplib, pyodbc, pymysql > Traceback (most recent call last): > File "C:\Users\Jon\Downloads\web2py_src\web2py\gluon\restricted.py", > line 219, in restricted > exec(ccode, environment) > File "applications\old_app\models\menu.py", line 19, in <module> > if auth.has_membership('managers'): > File "C:\Users\Jon\Downloads\web2py_src\web2py\gluon\authapi.py", line > 592, in has_membership > group_id = self.id_group(group_id) # interpret group_id as a role > File "C:\Users\Jon\Downloads\web2py_src\web2py\gluon\authapi.py", line > 454, in id_group > rows = self.db(self.table_group().role == role).select() > File "C:\Python27\lib\site-packages\pydal\objects.py", line 2250, in > select > return adapter.select(self.query, fields, attributes) > File "C:\Python27\lib\site-packages\pydal\adapters\base.py", line 762, > in select > return self._select_aux(sql, fields, attributes, colnames) > File "C:\Python27\lib\site-packages\pydal\adapters\base.py", line 718, > in _select_aux > rows = self._select_aux_execute(sql) > File "C:\Python27\lib\site-packages\pydal\adapters\base.py", line 712, > in _select_aux_execute > self.execute(sql) > File "C:\Python27\lib\site-packages\pydal\adapters\__init__.py", line > 67, in wrap > return f(*args, **kwargs) > File "C:\Python27\lib\site-packages\pydal\adapters\base.py", line 412, > in execute > rv = self.cursor.execute(command, *args[1:], **kwargs) > File "C:\Python27\lib\site-packages\pymysql\cursors.py", line 170, in > execute > result = self._query(query) > File "C:\Python27\lib\site-packages\pymysql\cursors.py", line 328, in > _query > conn.query(q) > File "C:\Python27\lib\site-packages\pymysql\connections.py", line 517, > in query > self._affected_rows = self._read_query_result(unbuffered=unbuffered) > File "C:\Python27\lib\site-packages\pymysql\connections.py", line 732, > in _read_query_result > result.read() > File "C:\Python27\lib\site-packages\pymysql\connections.py", line 1075, > in read > first_packet = self.connection._read_packet() > File "C:\Python27\lib\site-packages\pymysql\connections.py", line 684, > in _read_packet > packet.check_error() > File "C:\Python27\lib\site-packages\pymysql\protocol.py", line 220, in > check_error > err.raise_mysql_exception(self._data) > File "C:\Python27\lib\site-packages\pymysql\err.py", line 109, in > raise_mysql_exception > raise errorclass(errno, errval) > ProgrammingError: (1146, u"Table 'test2.auth_group' doesn't exist") > > > <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail> > Libre > de virus. www.avast.com > <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail> > <#m_-5813125044794022460_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2> > > On Tue, Feb 5, 2019 at 10:38 AM Jon Subscripted < > jonsubscripti...@gmail.com> wrote: > >> Hi everyone, >> I took a look at cpdb.py code and saw that "-d" option is just used to >> find where "dal.py" and add the folder sys.path. >> >> So, instead of the relative path, I decided to use the absolute path. I >> do not get the "could not set DAL" exception anymore, but now I get the >> following error: >> >> "Field auth_cas.id is already bound to a table" >> >> And the warning regarding the "plural_rules". >> This is the command I executed: >> >> C:\Users\Jon\Downloads\web2py_winAPPLIANCES\web2py>python scripts/cpdb.py >> -f applications/paravolcar10enero_tarde/databases -y >> sqlite://storage.sqlite -Y sqlite://storage3.sqlite -d >> C:\Users\Jon\Downloads\web2py_winAPPLIANCES\web2py\gluon >> No handlers could be found for logger "web2py" >> WARNING:root:Unable to import plural rules: No module named plural_rules >> creating tables... >> EXCEPTION: could not make a copy of the database >> Field auth_cas.id is already bound to a table >> >> Any suggestions? What does this mean? >> Thanks, Jon. >> >> PS. I'm just using sqlite to sqlite copy for now, for the sake of >> simplicity. >> >> On Mon, Feb 4, 2019 at 10:06 AM Jon Subscripted < >> jonsubscripti...@gmail.com> wrote: >> >>> Hi Dave, >>> Yes, if you refer to the Python installed in the computer I'm using >>> Python 2.7.5. >>> >>> C:\Users\Jon\Downloads\web2py_winAPPLIANCES\web2py>python >>> scripts/cpdb.py -f applications/paravolcar10enero_tarde/databases -y >>> sqlite://storage.sqlite -Y sqlite://storage3.sqlite -d ../gluon >>> No handlers could be found for logger "web2py" >>> WARNING:root:Unable to import plural rules: No module named plural_rules >>> EXCEPTION: could not set DAL >>> No module named dal >>> creating tables... >>> EXCEPTION: could not make a copy of the database >>> 'NoneType' object is not iterable >>> >>> C:\Users\Jon\Downloads\web2py_winAPPLIANCES\web2py>python.exe >>> Python 2.7.15 (v2.7.15:ca079a3ea3, Apr 30 2018, 16:22:17) [MSC v.1500 32 >>> bit (Intel)] on win32 >>> Type "help", "copyright", "credits" or "license" for more information. >>> >>> >>> >>> Thanks, Jon. >>> >>> PS. I'm not fully aware of the relationship between the existing Python >>> installation in the computer and the pre-packed Python (delivered as part >>> of Web2py). >>> >>> On Sun, Feb 3, 2019 at 10:21 PM Dave S <snidely....@gmail.com> wrote: >>> >>>> >>>> >>>> On Saturday, February 2, 2019 at 6:05:55 AM UTC-8, Jonsubs wrote: >>>>> >>>>> Hi everyone, >>>>> I'm trying to copy my database (already populated) using cbpd.py but I >>>>> get an error. >>>>> (I'm working in Windows 10 with Web2py >>>>> 2.17.2-stable+timestamp.2018.10.06.18.54.02) >>>>> >>>>> >>>> So you're using the in-box python, which is python2? >>>> >>>> /dps >>>> >>>> >>>>> 1st I changed the database URI in appconfig.ini from >>>>> sqlite://storage.sqlite to sqlite://storage3.sqlite >>>>> 2nd I checked with SQLite Browser that sqlite://storage3.sqlite was >>>>> created and tables are created also (but empty) >>>>> 3rd I launched the command below, but I does not work. >>>>> >>>>> C:\Users\Jon\Downloads\web2py_winAPPLIANCES\web2py>python >>>>> scripts/cpdb.py -f applications/paravolcar10enero_tarde/databases -y >>>>> sqlite://storage.sqlite -Y sqlite://storage3.sqlite -d ../gluon >>>>> No handlers could be found for logger "web2py" >>>>> WARNING:root:Unable to import plural rules: No module named >>>>> plural_rules >>>>> EXCEPTION: could not set DAL >>>>> No module named dal >>>>> creating tables... >>>>> EXCEPTION: could not make a copy of the database >>>>> 'NoneType' object is not iterable >>>>> >>>>> Any suggestions? I do not really know how to interpret the error. >>>>> Thanks, Jon. >>>>> >>>> -- >>>> 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 web2py+unsubscr...@googlegroups.com. >>>> For more options, visit https://groups.google.com/d/optout. >>>> >>> > > <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail> > Libre > de virus. www.avast.com > <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail> > <#m_-5813125044794022460_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2> > -- 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 web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.