[sqlalchemy] Re: How to ignore primary key errors on insert

2008-05-07 Thread Alexis B
Oh right, I'll do this . ( I was looking so hard on postgres features that I forgot the python ones ... ) Thanks On May 6, 4:40 pm, Michael Bayer [EMAIL PROTECTED] wrote: just use try/except from sqlalchemy import exceptions try: engine.execute(mytable.insert(), **kwargs) except

[sqlalchemy] eagerload vs. joins

2008-05-07 Thread David Gardner
I've got a small problem, I want to be able to join two related tables in a query (in my case JobInfo-Chunk-Pass) so that I could use the second table in my order_by(), I would also like them to be eagerloaded. The problem is that in the resulting SQL the tables are joined twice, once for the

[sqlalchemy] refresh(object)

2008-05-07 Thread Werner F. Bruhin
I have a problem with refresh, doing something along these lines: object.subobject object.otherviewofsubobject (this is actually a Firebird SQL view - which I use for read only access) do some update to subobject session.flush() refresh(object) object.subobject object.otherviewofsubobject

[sqlalchemy] appending an object through an 2-level association table

2008-05-07 Thread Matt Haggard
I'm trying to figure out how to add objects through the ORM. (My schema and mappings are below.) In the shell, I can do the following: newQ = Question() # ... set the attributes of newQ mytype = session.query(QType).first() mytype.my_sections # correctly gives all the sections that belong to

[sqlalchemy] Re: eagerload vs. joins

2008-05-07 Thread Michael Bayer
On May 7, 2008, at 1:52 PM, David Gardner wrote: I've got a small problem, I want to be able to join two related tables in a query (in my case JobInfo-Chunk-Pass) so that I could use the second table in my order_by(), I would also like them to be eagerloaded. The problem is that in the

[sqlalchemy] IN queries using parameters

2008-05-07 Thread sbhatt
Hello All, I am facing a problem using the IN queries in sqlalchemy. I am using sqlalchemy-0.4.5-py2.4.egg for the following. The documentation at sqlalchemy.org states the following example for showing IN queries session.query(Address).filter(Address.email_address.in_(['[EMAIL PROTECTED]',

[sqlalchemy] Re: refresh(object)

2008-05-07 Thread Michael Bayer
On May 7, 2008, at 2:08 PM, Werner F. Bruhin wrote: I have a problem with refresh, doing something along these lines: object.subobject object.otherviewofsubobject (this is actually a Firebird SQL view - which I use for read only access) do some update to subobject session.flush()

[sqlalchemy] Re: IN queries using parameters

2008-05-07 Thread Michael Bayer
On May 7, 2008, at 3:01 PM, sbhatt wrote: But I want to run the query based on the arguments provided to the function, where in the list [1,2,3,4] will be passed in as an argument as studentidlist = [1,2,3,4]. Hence when I write the following query , it throws me a SQLError: (DatabaseError)

[sqlalchemy] Re: IN queries using parameters

2008-05-07 Thread sbhatt
Thanks for the help I was trying to make the code run on both 0.3.11 and 0.4, and hence the error. In 0.4.5 I can successfully call the following statements, and get results getStudentByStudentIdList(studentidlist): session.query(Student).filter(Student.c.studentid.in_(studentidlist)).all()

[sqlalchemy] Re: eagerload vs. joins

2008-05-07 Thread David Gardner
Tried that still no luck. If it helps any, the job_info table is temporary and doesn't have any keys, or foreign keys, since it is being constantly updated. So I am doing the join in my mapper: qstat_mapper = mapper(JobInfo, qstat_table, primary_key=[qstat_table.c.job_number], properties={

[sqlalchemy] Re: eagerload vs. joins

2008-05-07 Thread Michael Bayer
On May 7, 2008, at 5:15 PM, David Gardner wrote: Tried that still no luck. If it helps any, the job_info table is temporary and doesn't have any keys, or foreign keys, since it is being constantly updated. So I am doing the join in my mapper: qstat_mapper = mapper(JobInfo, qstat_table,

[sqlalchemy] Re: eagerload vs. joins

2008-05-07 Thread David Gardner
Sorry, both contains_eager and eagerload_all() work, however both produce the same SQL, where both related tables are joined twice. They both produce: SELECT several columns here FROM farm.qstatus LEFT OUTER JOIN farm.chunk ON farm.chunk.queue_job_id = farm.qstatus.job_number LEFT OUTER JOIN

[sqlalchemy] relation that only fails with a backref

2008-05-07 Thread Bobby Impollonia
secondary_table = Table('secondary', Base.metadata, Column('left_id', Integer, ForeignKey('parent.id'), nullable=False), Column('right_id', Integer, ForeignKey('parent.id'), nullable=False)) class Parent(Base): __tablename__ = 'parent' id = Column(Integer, primary_key=True)

[sqlalchemy] Re: eagerload vs. joins

2008-05-07 Thread Michael Bayer
On May 7, 2008, at 6:12 PM, David Gardner wrote: Sorry, both contains_eager and eagerload_all() work, however both produce the same SQL, where both related tables are joined twice. They both produce: ah, my apologies, I was recommending a usage which has only been added in 0.5.

[sqlalchemy] Re: relation that only fails with a backref

2008-05-07 Thread Michael Bayer
On May 7, 2008, at 7:23 PM, Bobby Impollonia wrote: secondary_table = Table('secondary', Base.metadata, Column('left_id', Integer, ForeignKey('parent.id'), nullable=False), Column('right_id', Integer, ForeignKey('parent.id'), nullable=False)) class Parent(Base):