[sqlalchemy] What might cause QueuePool limit of size 5 overflow 10 reached?

2009-08-13 Thread 一首诗
I occasionally got QueuePool limit of size 5 overflow 10 reached. I don't call session.close() after I don't need them. Because I think GC will do that. But now, it seems that I am losting connections somewhere. Should I call session.close after I use them? Should I use try.. finally... to

[sqlalchemy] Re: Fwd: sql soup not persisting insert

2009-08-13 Thread Philip Jenvey
On Aug 12, 2009, at 12:23 AM, Lilian David wrote: Hi, The attached script doesn't persist a sqlsoup insert. Would anyone happen to know what must be changed in the script to allow the insert to be persisted ? from sqlalchemy.ext.sqlsoup import Session Session.commit() This was brought

[sqlalchemy] can't compare offset-naive and offset-aware datetimes

2009-08-13 Thread Julien Cigar
Hello, I'm using PostgreSQL / SQLAlchemy 0.5.5 and I build my Table objects using the reflection feature : {{{ metadata = schema.MetaData() metadata.reflect(bind=_engine) }}} I have a table which has a timestamptz column and when I try to insert a (for example) datetime(2009, 13, 12, 10,

[sqlalchemy] Re: can't compare offset-naive and offset-aware datetimes

2009-08-13 Thread Julien Cigar
I just tried : datetime(2009, 13, 12, 10, 12, tzinfo=pytz.timezone('Europe/Brussels')) instead of : datetime(2009, 13, 12, 10, 12) .. but without success, still the same error .. On Thu, 2009-08-13 at 11:27 +0200, Julien Cigar wrote: Hello, I'm using PostgreSQL / SQLAlchemy 0.5.5 and I

[sqlalchemy] Loading classes polymorphically

2009-08-13 Thread rake
Assuming I have the following simplified classes: class A(Base): __tablename__ = 'a' id = Column(Integer, primary_key=True) type = Column(Unicode) enabled = Column(Boolean) __mapper_args__ = {'polymorphic_on': type} class B(A): __tablename__ = 'b' __mapper_args__ =

[sqlalchemy] filtering eagerloaded properties?

2009-08-13 Thread Sean
I have a relatively, (at least I think), straightforward question that I've been having a difficult time tracking down an answer to. I have Groups that have Users that have Tasks and I want to write one query that gives me the group's users, and each user's incomplete tasks. Is there a common

[sqlalchemy] Adjacency list problem

2009-08-13 Thread droolz
Hi, I have a problem with an adjacency list table, my knowledge of DB design is flakey at best so please bear with me in terminology and my attempt at an explanation. I have a table/class/mapping as follows (the DB is sqlite3): invoices_table = Table('invoices', metadata, Column('id',

[sqlalchemy] Re: Loading classes polymorphically

2009-08-13 Thread Michael Bayer
you're looking for query.with_polymorphic(). see the mapping documentation section on joined table inheritance for details. rake wrote: Assuming I have the following simplified classes: class A(Base): __tablename__ = 'a' id = Column(Integer, primary_key=True) type =

[sqlalchemy] Re: Adjacency list problem

2009-08-13 Thread Michael Bayer
droolz wrote: mapper(ArkInvoice, invoices_table, properties={ 'entries': relation(ArkInvoiceEntry, secondary=invoice_entries_primary_table, backref='invoice', cascade=all, delete, delete-orphan), 'user': relation(ArkUsers, backref='user'), 'child_invoices':relation(ArkInvoice,

[sqlalchemy] Re: filtering eagerloaded properties?

2009-08-13 Thread Ants Aasma
There are two reasonable options for this, one is to select tuples of group, user, task and join them together with appropriate conditions: session.query(Group, User, Task).outerjoin(Group.users).outerjoin ((Task, (Task.user_id == User.id) ~Task.complete)) the other option is to create a new

[sqlalchemy] Re: filtering eagerloaded properties?

2009-08-13 Thread Michael Bayer
use query.join(). its in the ORM tutorial. Sean wrote: I have a relatively, (at least I think), straightforward question that I've been having a difficult time tracking down an answer to. I have Groups that have Users that have Tasks and I want to write one query that gives me the group's

[sqlalchemy] Re: how sum elements with filters

2009-08-13 Thread Ants Aasma
Something like the following should work: session.query(Position, func.sum(Stats.points)).join(Stats.league, Player.position)\ .filter(Player.team == 'Some team').group_by(Position) On Aug 11, 9:08 pm, Doron Tal doron.tal.l...@gmail.com wrote: Hi sqlalchemy, I'm a newbie to SA. I hope

[sqlalchemy] Re: can't compare offset-naive and offset-aware datetimes

2009-08-13 Thread Didip Kerabat
Print out your Table object, see if that column was defined as you expected by reflect() On Aug 13, 2009, at 3:29 AM, Julien Cigar jci...@ulb.ac.be wrote: I just tried : datetime(2009, 13, 12, 10, 12, tzinfo=pytz.timezone('Europe/ Brussels')) instead of : datetime(2009, 13, 12, 10,

[sqlalchemy] Re: Adjacency list problem

2009-08-13 Thread Jules Stevenson
the mapping seems perfect to me.  parent_invoice would only be None for the actual parent.  perhaps there's some issue with your usage.   check your SQL echoing to make sure things are as expected. My bad, was using 5.0, not 5.5 - just upgraded and it works fine.

[sqlalchemy] Re: Loading classes polymorphically

2009-08-13 Thread rake
Thanks your quick respone, that is exactly what I was looking for. On Aug 13, 10:40 am, Michael Bayer mike...@zzzcomputing.com wrote: you're looking for query.with_polymorphic().  see the mapping documentation section on joined table inheritance for details. rake wrote: Assuming I have

[sqlalchemy] Testing SQLAlchemy based app? (Tutorial?)

2009-08-13 Thread AF
Hello, I'm writing a basic SQLAlchemy application, and have started to explore the concept of unit testing in general and specifically with nose. Since I am new to both SQLAlchey and nose, I do not know where to start. Right now the app is at the point where: 1) The tables are defined with

[sqlalchemy] AttributeError: 'long' object has no attribute 'decode' on session.query()

2009-08-13 Thread dvschramm
client_id = 309 dbclient = session.query(dbclientclass).filter (dbclientclass.client_id==client_id).one() results in AttributeError: 'long' object has no attribute 'decode' I tried just session.query(dbclientclass).all() and it results in the same error. my class looks as follows: class

[sqlalchemy] Re: AttributeError: 'long' object has no attribute 'decode' on session.query()

2009-08-13 Thread Michael Bayer
sounds like one of your column types is incorrect (and assuming convert_unicode=True on engine). otherwise theres no way to know the issue without a stack trace. dvschramm wrote: client_id = 309 dbclient = session.query(dbclientclass).filter (dbclientclass.client_id==client_id).one()

[sqlalchemy] Re: AttributeError: 'long' object has no attribute 'decode' on session.query()

2009-08-13 Thread darian schramm
Yes, you are right. I checked my column types and there was one incorrect column. Thanks! - Darian V Schramm On Thu, Aug 13, 2009 at 2:20 PM, Michael Bayermike...@zzzcomputing.com wrote: sounds like one of your column types is incorrect (and assuming convert_unicode=True on engine).  

[sqlalchemy] Re: Materialized Path for SQLAlchemy Declarative Base

2009-08-13 Thread Anton Gritsay
Hi, Allen! You can use something like this (yeah, I know that it isn't declarative in any way): class Node(Base): __tablename__ = 'node' id = Column(Integer, primary_key=True) parent_id = Column(ForeignKey('node.id')) parent = relation(Node,

[sqlalchemy] Re: Materialized Path for SQLAlchemy Declarative Base

2009-08-13 Thread allen.fowler
On Aug 13, 2:37 pm, Anton Gritsay gene...@angri.ru wrote: Hi, Allen! You can use something like this (yeah, I know that it isn't declarative in any way):     class Node(Base):         __tablename__ = 'node'         id = Column(Integer, primary_key=True)         parent_id =

[sqlalchemy] Re: Materialized Path for SQLAlchemy Declarative Base

2009-08-13 Thread Michael Bayer
On Aug 13, 2009, at 9:23 PM, allen.fowler wrote: On Aug 13, 2:37 pm, Anton Gritsay gene...@angri.ru wrote: Hi, Allen! You can use something like this (yeah, I know that it isn't declarative in any way): class Node(Base): __tablename__ = 'node' id =

[sqlalchemy] Re: Testing SQLAlchemy based app? (Tutorial?)

2009-08-13 Thread Didip Kerabat
nose works by running python files and methods that contain the word 'test', some people use nose to call their UnitTest objects. But you don't have to do this, you can get up to speed by using assert x == y for example. As 1 possible implementation, you can have setup() method in your test file