[sqlalchemy] Unsaved, pending instance and is an orphan problem

2009-07-23 Thread Victor Lin
Hi, I am writing a turbogears2 application, with elixir. I got a problem when I try to create an new entity and attach it to another entity. I create a simple program to repruduce the problem: from elixir import * class User(Entity): name = Field(Unicode) site = OneToOne('Site', cascade

[sqlalchemy] Re: Declarative, correlated subqueries

2009-07-23 Thread Michael Bayer
On Jul 23, 2009, at 8:43 PM, Gregg Lind wrote: > > Hm. I appreciate the help, but something is clearly still failing > here. > >> session.query(Route,*sq.c).join(sq.c.max_hop) > ArgumentError: Can't find any foreign key relationships between > 'route' and 'max_hop' > > Maybe the filter based

[sqlalchemy] Re: Declarative, correlated subqueries

2009-07-23 Thread Gregg Lind
Hm. I appreciate the help, but something is clearly still failing here. > session.query(Route,*sq.c).join(sq.c.max_hop) ArgumentError: Can't find any foreign key relationships between 'route' and 'max_hop' Maybe the filter based solution is just fine here :) On Thu, Jul 23, 2009 at 7:29 PM,

[sqlalchemy] Re: Declarative, correlated subqueries

2009-07-23 Thread Michael Bayer
On Jul 23, 2009, at 5:20 PM, Gregg Lind wrote: > > How do I implement this join? If I do this: > > sq = > session > .query > (Route > .ts > ,Route > .startpoint,Route.target,func.max(Route.hop_id).label('max_hop')) > sq = sq.group_by(Route.ts,Route.startpoint,Route.target).subquery() > >

[sqlalchemy] Re: Declarative, correlated subqueries

2009-07-23 Thread Gregg Lind
On Thu, Jul 23, 2009 at 3:24 PM, Michael Bayer wrote: > im assuming you're using MySQL since the GROUP BY below doesn't > accommodate every column in the subquery (would be rejected by most DBs). Corrected. It was Sqlite, but good catch. > youll want to query each column individually that is p

[sqlalchemy] Re: Declarative, correlated subqueries

2009-07-23 Thread Michael Bayer
Gregg Lind wrote: > > I have read over > http://www.sqlalchemy.org/docs/05/ormtutorial.html#using-subqueries > and http://www.mail-archive.com/sqlalchemy@googlegroups.com/msg11439.html, > but I'm having trouble putting the pieces together. > > In the demo() below, I want to find the row in the dat

[sqlalchemy] Declarative, correlated subqueries

2009-07-23 Thread Gregg Lind
I have read over http://www.sqlalchemy.org/docs/05/ormtutorial.html#using-subqueries and http://www.mail-archive.com/sqlalchemy@googlegroups.com/msg11439.html, but I'm having trouble putting the pieces together. In the demo() below, I want to find the row in the database with the max for every un

[sqlalchemy] Re: Doubts on relation with cascade & delete by backend

2009-07-23 Thread Michael Bayer
add passive_deletes = True sandro dentella wrote: > > Hi, > > I have a simple setup that may be summarized as: > > class User(Base): >__tablename__ = 'user' >name = Column(String(20), primary_key=True) > > class Mail(Base): >__tablename__ = 'address' >mail = Co

[sqlalchemy] Doubts on relation with cascade & delete by backend

2009-07-23 Thread sandro dentella
Hi, I have a simple setup that may be summarized as: class User(Base): __tablename__ = 'user' name = Column(String(20), primary_key=True) class Mail(Base): __tablename__ = 'address' mail = Column(String(20), primary_key=True) user_name = Column(ForeignKey(

[sqlalchemy] Re: lazy=False generated bad SQL

2009-07-23 Thread Michael Bayer
Mike Conley wrote: > I don't know if this is a bug or I don't understand eager loading eager loading doesn't understand your string "bullets.position" - it renders it directly as you've specified and can't do anything intelligent with it such as alias it. Specify it as bullets.c.position, or to

[sqlalchemy] lazy=False generated bad SQL

2009-07-23 Thread Mike Conley
I don't know if this is a bug or I don't understand eager loading When I try to eager load a relation containing an order_by clause, the generated SQL fails. It seems that the generated SQL does not account for the fact that the table is internally aliased by SQLAlchemy in the query. File "c:\pyt

[sqlalchemy] Re: 'pool_recycle' is not working

2009-07-23 Thread iSean
Thank you, Michael I misunderstood the role of pool_recycle. On Jul 23, 9:21 pm, Michael Bayer wrote: > On Jul 23, 2009, at 3:44 AM, iSean wrote: > > > > > > > Hi, > > > I think 'pool_recycle' is not working. My configuration is: > > > MySql wait_timeout=10 > > pool_size=10 > > pool_recycle=5

[sqlalchemy] Re: 'pool_recycle' is not working

2009-07-23 Thread Michael Bayer
On Jul 23, 2009, at 3:44 AM, iSean wrote: > > Hi, > > I think 'pool_recycle' is not working. My configuration is: > > MySql wait_timeout=10 > pool_size=10 > pool_recycle=5 > max_overflow=2 > > I do one select first, and sleep 15 seconds waiting for connection > timeout, at last do other one sele

[sqlalchemy] 'pool_recycle' is not working

2009-07-23 Thread iSean
Hi, I think 'pool_recycle' is not working. My configuration is: MySql wait_timeout=10 pool_size=10 pool_recycle=5 max_overflow=2 I do one select first, and sleep 15 seconds waiting for connection timeout, at last do other one select. It raised Exception 'MySQL server has gone away'. And I remo

[sqlalchemy] Re: autoload of db view treating columns as Decimal

2009-07-23 Thread Randy Syring
On Jul 23, 5:04 am, "King Simon-NFHD78" wrote: > When I run your script, I get the correct output, using Python 2.5.1, SA > 0.5.4p2, sqlite3 version 2.3.2. Perhaps the bug is in the version of > SQLite that you are using? > > What happens if you run your query using the SQLite command-line tools?

[sqlalchemy] More SA, pyodbc, *nux and MSSQL problems

2009-07-23 Thread Ed Singleton
I've managed to get SA (0.6 branch) and pyodbc connecting to an MSSQL db on Mac OS X, but I've recently been trying to get it working on linux (Debian Lenny) and have been hitting some problems. It's definitely working to some degree. Adding "TDS_Version = 8.0" to my odbc.ini fixed some un

[sqlalchemy] Re: autoload of db view treating columns as Decimal

2009-07-23 Thread King Simon-NFHD78
> -Original Message- > From: sqlalchemy@googlegroups.com > [mailto:sqlalch...@googlegroups.com] On Behalf Of Randy Syring > Sent: 23 July 2009 07:23 > To: sqlalchemy > Subject: [sqlalchemy] Re: autoload of db view treating > columns as Decimal > > > Well, I am not really sure what the