anunnakian / sqlautocode

Automatically exported from code.google.com/p/sqlautocode
Other
0 stars 0 forks source link

ArgumentError: Can't change schema of existing table -- when schema is not specified #9

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Configuration: Windows Vista, Python 2.5.2, sqlalchemy 0.4.7p1, sqlautocode
0.5.1

What steps will reproduce the problem?
1. Run sqlautocode on an existing database which support schemas with
foreign keys defined
2. Specify a child table followed by a parent table - works fine.
3. Specify a parent table followed by a child table: fails when processing
the child table

Workaround the problem by specifying the schema or by commenting out lines
55 and 56 from __init__.py.  Overwriting the schema on the parent table
causes the loading of the child table to fail.

PS C:\Users\jaraco\projects\sqlautocode> ./autocode postgres://eei_devel@
-o model.py --tables 'user_group,groups'
Starting...
Generating python model for table user_group
Generating python model for table groups
Output written to model.py

---

PS C:\Users\jaraco\projects\sqlautocode> ./autocode postgres://eei_devel@
-o model.py --tables 'groups,user_group'
Starting...
Generating python model for table groups
Generating python model for table user_group
Traceback (most recent call last):
  File "C:\Users\jaraco\projects\sqlautocode\autocode.py", line 4, in <module>
    sqlautocode.main()
  File "C:\Users\jaraco\projects\sqlautocode\sqlautocode\__init__.py", line
54, in main
    autoload=True)
  File "c:\program files
(x86)\python\lib\site-packages\sqlalchemy-0.4.7p1-py2.5.egg\sqlalchemy\schema.py
",
line 110, in __call__
    return type.__call__(self, name, metadata, *args, **kwargs)
  File "c:\program files
(x86)\python\lib\site-packages\sqlalchemy-0.4.7p1-py2.5.egg\sqlalchemy\schema.py
",
line 226, in __init__
    _bind_or_error(metadata).reflecttable(self,
include_columns=include_columns)
  File "c:\program files
(x86)\python\lib\site-packages\sqlalchemy-0.4.7p1-py2.5.egg\sqlalchemy\engine\ba
se.py",
line 1275, in reflecttable
    self.dialect.reflecttable(conn, table, include_columns)
  File "c:\program files
(x86)\python\lib\site-packages\sqlalchemy-0.4.7p1-py2.5.egg\sqlalchemy\databases
\postgres.py",
line 600, in reflecttable
    autoload_with=connection)
  File "c:\program files
(x86)\python\lib\site-packages\sqlalchemy-0.4.7p1-py2.5.egg\sqlalchemy\schema.py
",
line 103, in __call__
    table._init_existing(*args, **kwargs)
  File "c:\program files
(x86)\python\lib\site-packages\sqlalchemy-0.4.7p1-py2.5.egg\sqlalchemy\schema.py
",
line 239, in _init_existing
    (self.schema, schema))
sqlalchemy.exceptions.ArgumentError: ("Can't change schema of existing
table from '%s' to '%s'", (None, 'public'))

Original issue reported on code.google.com by jaraco%jaraco.com@gtempaccount.com on 2 Oct 2008 at 6:24

GoogleCodeExporter commented 8 years ago
Any stable solution for this? Could currently get no exact idea of the problem.

Original comment by spamsch@gmail.com on 5 Oct 2008 at 11:03

GoogleCodeExporter commented 8 years ago

Original comment by spamsch@gmail.com on 5 Oct 2008 at 11:04

GoogleCodeExporter commented 8 years ago
Fix in r37.

Original comment by jaraco%jaraco.com@gtempaccount.com on 5 Oct 2008 at 1:59