You can create such a table, yes, if you are sure you should:

from sqlalchemy import *
e = create_engine('sqlite:///')
t = Table('foo', MetaData(e), Column('bar', Text))
t.create()

(or skip the last call if you are referencing an existing table in the DB)

The ORM part of SQLAlchemy does require a primary key to be specified. If 
the table has no primary key, you can define it in the mapper using the 
`primary_key` argument. Either:

class T(object):
    pass

from sqlalchemy.orm import mapper
mapper(T, t, primary_key=t.c.bar)

or using declarative:

from sqlalchemy.ext.declarative import declarative_base
Base = declarative_base(e)
class T2(Base):
    __table__ = t
    __mapper_args__ = {'primary_key': t.c.bar}

(But unless you really know what you're doing, this is not what you should 
be doing.)

Regards,

- Gulli

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/sqlalchemy/-/aJ84EkB79OkJ.
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