Thanks a lot for your tip. I found out that a lot of the tables in the database have no primary key, at least not officially. They have a unique index on one of the fields, so I can use that as the primary key.
Cheers! On May 25, 4:22 pm, GHZ <[email protected]> wrote: > you can check for primary key constraints using: > > select table_name, constraint_name from user_constraints where > constraint_type = 'P' > > the orm will need to know the primary keys, but if they do not exist > in the schema, you can set them when you reflect the table > > t = Table('t1', > meta, > Column('id', Integer, primary_key=True), > autoload=True) > > On 25 Mai, 10:23, "Urko M." <[email protected]> wrote: > > > > > The "primary_key" collection seems to be empty. For example, I am > > reflecting the table "teachers", and the result of: > > len(teachers.primary_key) > > is 0. > > > The table is there, and is reflected apparently correctly. And > > teachers.indexes shows me a correct list of indexes. I'm not an expert > > in Oracle, so maybe this is consistent with the way the database is > > created. I can't change that, as it is for a commercial product. > > > Are there any side effects if SQLAlchemy doesn't have a Primary Key > > for a table? > > > On May 24, 8:59 pm, Michael Bayer <[email protected]> wrote: > > > > On May 24, 2010, at 5:34 AM, Urko M. wrote: > > > > > Hi everyone, > > > > > I am starting out with SQLAlchemy, and I want to use it to reflect > > > > tables in an Oracle 10g database. > > > > > I have been successful in that, but it seems it is not reflecting the > > > > primary keys. Any ideas? > > > > Or any suggestion about how to check if the keys are getting reflected > > > > or not? > > > > you'd check the "primary_key" collection on the Table, > > > len(Table.primary_key). There's no issue I've seen before with PK > > > columns not reflecting on 10g. > > > > -- > > > 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 > > > athttp://groups.google.com/group/sqlalchemy?hl=en. > > > -- > > 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 > > athttp://groups.google.com/group/sqlalchemy?hl=en. > > -- > 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 > athttp://groups.google.com/group/sqlalchemy?hl=en. -- 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.
