Hi all,
SQLAlchemy 0.7.1 / Python 2.7.1 on Ubuntu 11.04 server / Apache 2.2.x
+ mod_wsgi 3.3.x
I am *very* new to SQLAlchemy, so please be kind. We are trying to use
SQLAlchemy with an existing database / tables. Our preference is to
use the Metadata auto discover mechanism so we don't have to define
each column name in the mapper classes (not opposed to writing out the
column names if that's what we have to do, just being lazy).
Consider the following definition of a class that maps to a table with
two columns, section_id (Integer, PK), section_name (String),
section_number (String)
Base = declarative_base()
Base.metadata.reflect(bind=db.engine)
class Section(Base):
__table__ = Base.metadata.tables['section']
all works well interacting with the database, we can insert, retrieve
records and of course refer to the columns as attributes of the Python
object.
We are writing code where we need to dynamically discover the primary
key of the table / object. I have Googled around to find that objects
should have a primary_key attribute that should give me what I am
after, but all the documentation I've found so far refer to 0.5 and
this obviously doesn't exists in 0.7
My question is, is there an equivalent of the primary_key property
which we can use to auto discover the primary key of an object.
Thanks for your time.
--
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en.