Re: [sqlalchemy] Re: negative implications of using multiple declarative Base classes

2010-08-24 Thread Chris Withers
avdd wrote: I'm glad you brought this up. It seems to me that the the declarative instrumentation keys classes by their unqualified class name, precluding using the same class name for different declarative subclasses (ie, in different modules). Indeed, but I suspect there's more to it than

[sqlalchemy] Session uses new connection after commit

2010-08-24 Thread Julien Demoor
Hi, I'm using PostgreSQL advisory locks in a multithreaded program. Worker threads acquire locks with session.execute(select([func.pg_advisory_lock(key)])) during a transaction and release them just after session.commit(). Sometimes however, the connection behind the thread's session will have

[sqlalchemy] where would you store meta data .. ?

2010-08-24 Thread Julien Cigar
Hello, I'm building a CMS-like webapp where I use inheritance a lot. One feature that I would like to allow is that when an user add a new section (a new container), he would be able to select the default with_polymorphic() clause, order_by, objects per page when browsing the container, etc.

[sqlalchemy] begginers query question

2010-08-24 Thread Dobrysmak
Hi guys. I've got a little problem with the sqlalchemy syntax. I've got two tables with relations: Table_Goups id int(4) PrimaryKey not null, name varchar(50) not null; and Table_User id int(4) Primary Key not null, login varchar(50) not null, id_group int(4) Foreign Key not null; i would

Re: [sqlalchemy] Re: negative implications of using multiple declarative Base classes

2010-08-24 Thread Michael Bayer
On Aug 24, 2010, at 3:04 AM, Chris Withers wrote: avdd wrote: I'm glad you brought this up. It seems to me that the the declarative instrumentation keys classes by their unqualified class name, precluding using the same class name for different declarative subclasses (ie, in different

Re: [sqlalchemy] Session uses new connection after commit

2010-08-24 Thread Michael Bayer
On Aug 24, 2010, at 6:12 AM, Julien Demoor wrote: Hi, I'm using PostgreSQL advisory locks in a multithreaded program. Worker threads acquire locks with session.execute(select([func.pg_advisory_lock(key)])) during a transaction and release them just after session.commit(). Sometimes

Re: [sqlalchemy] begginers query question

2010-08-24 Thread werner
Hi, On 24/08/2010 10:14, Dobrysmak wrote: Hi guys. I've got a little problem with the sqlalchemy syntax. I've got two tables with relations: Table_Goups id int(4) PrimaryKey not null, name varchar(50) not null; and Table_User id int(4) Primary Key not null, login varchar(50) not null,

Re: [sqlalchemy] begginers query question

2010-08-24 Thread werner
On 24/08/2010 15:53, werner wrote: Hi, On 24/08/2010 10:14, Dobrysmak wrote: Hi guys. I've got a little problem with the sqlalchemy syntax. I've got two tables with relations: Table_Goups id int(4) PrimaryKey not null, name varchar(50) not null; and Table_User id int(4) Primary Key not

[sqlalchemy] Re: Session uses new connection after commit

2010-08-24 Thread Julien Demoor
Thanks a lot, that solves my problem. Also it seems to work well without instantiating the scoped session, so this is perfect. On Aug 24, 3:13 pm, Michael Bayer mike...@zzzcomputing.com wrote: On Aug 24, 2010, at 6:12 AM, Julien Demoor wrote: Hi, I'm using PostgreSQL advisory locks in a

[sqlalchemy] TypeDecorator Problem with basic association pattern

2010-08-24 Thread Frank
Hello, I am trying to reflect the example from http://hg.sqlalchemy.org/sqlalchemy/file/04c17c7d88d6/examples/association/basic_association.py but with my own data structures. I want to manage nutrients, nutrient values and nutrition lists. Therefore I have created a custom data type weight

Re: [sqlalchemy] TypeDecorator Problem with basic association pattern

2010-08-24 Thread Michael Bayer
On Aug 24, 2010, at 11:03 AM, Frank wrote: Hello, I am trying to reflect the example from http://hg.sqlalchemy.org/sqlalchemy/file/04c17c7d88d6/examples/association/basic_association.py but with my own data structures. I want to manage nutrients, nutrient values and nutrition lists.

Re: [sqlalchemy] upgrading code with prop.backref from 0.5 - 0.6

2010-08-24 Thread Alessandro Dentella
On Sat, Aug 21, 2010 at 01:45:48PM -0400, Michael Bayer wrote: columns in a property column = prop.columns[0] props = [] for pr in mapper.iterate_properties: if isinstance(pr, properties.RelationProperty): if pr.direction.name in ('MANYTOONE',):

[sqlalchemy] orm object, before after

2010-08-24 Thread Michael Hipp
I'm holding an orm object that will have changes made to it. Once done it will be passed to the business logic layer that will have to make decisions from the before and after state of the object... What's the best way to get an object, save its state ('before'), modify it ('after) without

Re: [sqlalchemy] orm object, before after

2010-08-24 Thread Michael Bayer
On Aug 24, 2010, at 2:08 PM, Michael Hipp wrote: I'm holding an orm object that will have changes made to it. Once done it will be passed to the business logic layer that will have to make decisions from the before and after state of the object... What's the best way to get an object,

[sqlalchemy] Extending DeclarativeBase

2010-08-24 Thread waugust
Greetings, I was playing around and trying to extend the DeclarativeBase with some Elixir like functions... I may be to green in Python itself that I'm missing something though, here's what I got... class ModelBase(DeclarativeMeta): @classmethod def get(cls, id): row =

Re: [sqlalchemy] orm object, before after

2010-08-24 Thread Michael Hipp
On 8/24/2010 1:51 PM, Michael Bayer wrote: On Aug 24, 2010, at 2:08 PM, Michael Hipp wrote: I'm holding an orm object that will have changes made to it. Once done it will be passed to the business logic layer that will have to make decisions from the before and after state of the object...

Re: [sqlalchemy] orm object, before after

2010-08-24 Thread Michael Bayer
Michael Hipp wrote: On 8/24/2010 1:51 PM, Michael Bayer wrote: On Aug 24, 2010, at 2:08 PM, Michael Hipp wrote: I'm holding an orm object that will have changes made to it. Once done it will be passed to the business logic layer that will have to make decisions from the before and after

Re: [sqlalchemy] Extending DeclarativeBase

2010-08-24 Thread Michael Bayer
On Aug 24, 2010, at 7:54 PM, waugust wrote: Greetings, I was playing around and trying to extend the DeclarativeBase with some Elixir like functions... I may be to green in Python itself that I'm missing something though, here's what I got... class ModelBase(DeclarativeMeta):

[sqlalchemy] How to delete in ORM without querying first?

2010-08-24 Thread Russell Warren
In the code below I set up two users using an orm session, and then delete one of them with a second orm session. import sqlalchemy as sa from sqlalchemy.ext.declarative import declarative_base from sqlalchemy.orm import sessionmaker Base = declarative_base() class User(Base):

[sqlalchemy] Re: How to delete in ORM without querying first?

2010-08-24 Thread Russell Warren
On Aug 25, 12:01 am, Fernando Takai fernando.ta...@gmail.com wrote: Have you tried: #delete the fred user... name_to_delete = fred s2 = Session() s2.query(User).filter_by(name = name_to_delete).delete() s2.commit() ? No I had not... :( That works absolutely perfectly, though with