On Aug 17, 2011, at 10:15 PM, Ygor Lemos wrote:

> I tried the following for manually mapping the tables:
> 
> 
> #!/usr/bin/env python3
> # -*- coding: utf-8 -*-
> 
> from sqlalchemy import *
> from sqlalchemy import dialects
> from sqlalchemy import sql
> from sqlalchemy.orm import *
> from sqlalchemy.ext.declarative import declarative_base
> from sqlalchemy.sql.expression import *
> 
> engine = create_engine("mysql+oursql://XXXXXXXX:XXXXXXX@XXXXXXXXXXXXXX/
> XXXXXXX?charset=utf8&use_unicode=True&autoping=True", echo=True)
> metadata = MetaData(engine)
> 
> Base = declarative_base()
> 
> class User(Base):
> 
>    __tablename__ = "users"
> 
>    id = Column(Integer, primary_key=True),
>    login = Column(String(25)),
>    name = Column(String(50)),
>    passwd = Column(String(100)),
>    email = Column(String(100)),
>    atype = Column(String(50)),
>    active = Column(Boolean),
>    customers_id = Column('customers_id', Integer,
> ForeignKey('customers.id')),

all of those commas at the end of each line results in the class having a tuple 
called "id" in it, rather than a set of attributes "id", "login", "name" etc 
which declarative can interpret as mapping directives.



-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to