tryin to learn extract database models, all database is generated from
web2py app, then create new web2py app named test1, copy the database
(sqlite) to test1 databases folder, for mysql test is remaining from
another web2py app
*sqlite using terminal*
python ~/web2py/scripts/extract_sqlite_models.py
~/web2py/applications/test1/databases/test1.sqlite
*result in terminal (cutted)*
legacy_db = DAL('sqlite://mutualfunds.sqlite')
legacy_db.define_table('auth_user',
migrate=False)
*mysql using terminal*
python ~/web2py/scripts/extract_mysql_models.py root:@localhost/test1
*result in terminal (cutted)*
legacy_db = DAL('mysql://root:@localhost/test1')
legacy_db.define_table('auth_user',
Field('id','integer'),
Field('first_name','string'),
Field('last_name','string'),
Field('email','string'),
Field('username','string'),
Field('password','string'),
Field('registration_key','string'),
Field('reset_password_key','string'),
Field('registration_id','string'),
Field('is_active','string'),
Field('created_on','datetime'),
Field('created_by','integer'),
Field('modified_on','datetime'),
Field('modified_by','integer'),
Field('created_from','string'),
Field('modified_from','string'),
migrate=False)
*question:*
- why the result is different in define_table (sqlite and mysql)? can we
define the table without defining it's own field like sqlite result ?
- there are an error traceback with the dal constructor, seems must have
migrate=False or anything, even try at the define table add the migrate
parameter still meet the error traceback
*e.g.1*
legacy_db = DAL('sqlite://mutualfunds.sqlite')
*error traceback:*
Traceback (most recent call last):
File "/Users/MacBookPro/project/python/web2py/gluon/restricted.py", line
219, in restricted
exec(ccode, environment)
File
"/Users/MacBookPro/project/python/web2py/applications/test/models/db.py",
line 75, in <module>
auth.define_tables(username=False, signature=False)
File "/Users/MacBookPro/project/python/web2py/gluon/tools.py", line 2216,
in define_tables
super(Auth, self).define_tables(username, signature, migrate,
fake_migrate)._table_signature_list
File "/Users/MacBookPro/project/python/web2py/gluon/authapi.py", line
350, in define_tables
format='%(first_name)s %(last_name)s (%(id)s)'))
File
"/Users/MacBookPro/project/python/web2py/gluon/packages/dal/pydal/base.py",
line 586, in define_table
table = self.lazy_define_table(tablename, *fields, **args)
File
"/Users/MacBookPro/project/python/web2py/gluon/packages/dal/pydal/base.py",
line 620, in lazy_define_table
polymodel=polymodel)
File
"/Users/MacBookPro/project/python/web2py/gluon/packages/dal/pydal/adapters/base.py",
line 797, in create_table
return self.migrator.create_table(*args, **kwargs)
File
"/Users/MacBookPro/project/python/web2py/gluon/packages/dal/pydal/migrator.py",
line 277, in create_table
self.adapter.create_sequence_and_triggers(query, table)
File
"/Users/MacBookPro/project/python/web2py/gluon/packages/dal/pydal/adapters/base.py",
line 880, in create_sequence_and_triggers
self.execute(query)
File
"/Users/MacBookPro/project/python/web2py/gluon/packages/dal/pydal/adapters/__init__.py",
line 67, in wrap
return f(*args, **kwargs)
File
"/Users/MacBookPro/project/python/web2py/gluon/packages/dal/pydal/adapters/base.py",
line 412, in execute
rv = self.cursor.execute(command, *args[1:], **kwargs)
OperationalError: table "auth_user" already exists
*e.g.2*
legacy_db = DAL('sqlite://mutualfunds.sqlite', migrate = False,
fake_migrate = False, migrate_enabled = False, fake_migrate_all = False)
*error traceback:*
Traceback (most recent call last):
File "/Users/MacBookPro/project/python/web2py/gluon/restricted.py", line
219, in restricted
exec(ccode, environment)
File
"/Users/MacBookPro/project/python/web2py/applications/test/models/table.py",
line 3, in <module>
migrate = True, fake_migrate = True, migrate_enabled = True,
fake_migrate_all = True)
File
"/Users/MacBookPro/project/python/web2py/gluon/packages/dal/pydal/base.py",
line 571, in define_table
raise SyntaxError('table already defined: %s' % tablename)
SyntaxError: table already defined: auth_user
*conclusion:*
still can't work with legacy database with the extract database models
python script even the database is created by another web2py app.
any hints?
thx and best regards,
stifan
--
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.