unalloc / sqlautocode

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

declarative bug #17

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
I have an sqlite db with only 1 table without any primary key created with
ydbf from a legacy .dbf file.
If i run sqlautocode without -d, it's ok, but when i run it with -d, i get:

tamas@tami:~/svn/berado/utils/dbf2gdb$ sqlautocode -d
sqlite:///converted.db -o converted.py
Traceback (most recent call last):
  File "/usr/bin/sqlautocode", line 8, in <module>
    load_entry_point('sqlautocode==0.5.3', 'console_scripts', 'sqlautocode')()
  File "/usr/lib/python2.6/site-packages/sqlautocode/main.py", line 21, in main
    emit(repr(factory))
  File "/usr/lib/python2.6/site-packages/sqlautocode/declarative.py", line
115, in __repr__
    models = self.models
  File "/usr/lib/python2.6/site-packages/sqlautocode/declarative.py", line
143, in models
    return sorted((self.create_model(table) for table in
self.get_non_many_to_many_tables()), by__name__)
  File "/usr/lib/python2.6/site-packages/sqlautocode/declarative.py", line
143, in <genexpr>
    return sorted((self.create_model(table) for table in
self.get_non_many_to_many_tables()), by__name__)
  File "/usr/lib/python2.6/site-packages/sqlautocode/declarative.py", line
151, in create_model
    class Temporal(self.DeclarativeBase):
  File "/usr/lib/python2.6/site-packages/sqlalchemy/ext/declarative.py",
line 561, in __init__
    _as_declarative(cls, classname, dict_)
  File "/usr/lib/python2.6/site-packages/sqlalchemy/ext/declarative.py",
line 554, in _as_declarative
    cls.__mapper__ = mapper_cls(cls, table, properties=our_stuff,
**mapper_args)
  File "/usr/lib/python2.6/site-packages/sqlalchemy/orm/__init__.py", line
751, in mapper
    return Mapper(class_, local_table, *args, **params)
  File "/usr/lib/python2.6/site-packages/sqlalchemy/orm/mapper.py", line
198, in __init__
    self._configure_pks()
  File "/usr/lib/python2.6/site-packages/sqlalchemy/orm/mapper.py", line
439, in _configure_pks
    "key columns for mapped table '%s'" % (self,
self.mapped_table.description))
sqlalchemy.exc.ArgumentError: Mapper Mapper|Temporal|jovelem could not
assemble any primary key columns for mapped table 'jovelem'

Original issue reported on code.google.com by gbtami on 18 Sep 2009 at 8:54

GoogleCodeExporter commented 8 years ago

Original comment by gbtami on 18 Sep 2009 at 8:58

Attachments:

GoogleCodeExporter commented 8 years ago
I get similar errors with postgresql and mysql as well.

Original comment by stress...@gmail.com on 2 Oct 2009 at 11:48

GoogleCodeExporter commented 8 years ago
This problem surely is not related with sqlautocode, sqlalchemy needs any 
primary key in the table, otherwise the mapper will not work :)

Original comment by e...@epicware.com.ar on 14 Dec 2010 at 4:28

GoogleCodeExporter commented 8 years ago
The problem with this is primarily that it prevents running the conversion at 
all. I've attached a patch that simply skips tables it has problems with.
(Note that declarative seems to ignore the --tables option which is another 
issue)

Original comment by dav...@j5int.com on 5 Jan 2011 at 2:58

Attachments: