Hello,

I'm running sqlcodegen on a database, but the output code seems  buggy.

Most of the tables are converted as class in the code such as :




class FilterReceiver(Base):
    __tablename__ = 'filter_receiver'
    __table_args__ = (
        ForeignKeyConstraint(['id_item', 'id_attribute'], [u
'item_attribute.id_item', u'item_attribute.id_attribute']),
        Index('idx_filter_receiver', 'id_item', 'id_attribute')
    )


    id = Column(Integer, primary_key=True, server_default=text(
"nextval('filter_receiver_id_seq'::regclass)"))
    id_item = Column(Integer)
    id_attribute = Column(Integer)
    id_receiver_type = Column(ForeignKey(u'receiver_type.id'), index=True)


    item_attribute = relationship(u'ItemAttribute')
    receiver_type = relationship(u'ReceiverType')






But some of them are converted as variables, such as : 

t_receiver_type = Table(
    'receiver_type', metadata,
    Column('id', Integer, unique=True),
    Column('name', String(20), unique=True),
    Column('igs_defined', String(1)),
    Column('model', String(50))
)



And when I try to create an object related to any table, for example: 

import db
a = db.Country()

I get this error message: 

When initializing mapper Mapper|FilterReceiver|filter_receiver, expression 
> u'ReceiverType' failed to locate a name ("name 'ReceiverType' is not 
> defined"). If this is a class name, consider adding this relationship() to 
> the <class 'db.FilterReceiver'> class after both dependent classes have 
> been defined.



Am I doing something wrong ?

For information I'm using  sqlacodegen 1.1.6 and SQLAlchemy 1.0.13
the command used to generate the python file is 
sqlacodegen postgresql://USERNAME:PASSWORD@127.0.0.1/titi --outfile db.py


Thanks by advance for any information and advice

Jean-Luc Menut


-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to