[sqlalchemy] Setting language for a db session

2009-09-14 Thread gizli
Hi all, I am just starting to think about this topic so please dont shoot me if I missed the obvious :). There are many varieties of database errors. So, sometimes in our code, we need to let these errors be returned to the user. E.g. we would like a french guy using this application to have a

[sqlalchemy] Self Join

2009-09-14 Thread Paulo Aquino
I have 2 tables 'Product' and 'ProductPrice'. I want to get all valid products, a product is valid if it has both a valid 'Selling' and 'Buying' ProductPrice type. A ProductPrice is valid if the valid_from date = date.today() and valid_to = date.today(). Product Table: id | sku | principal

[sqlalchemy] 0.55, orm, varying relation join on criteria

2009-09-14 Thread me
For certain orm queries with a 1-to-many relation i want to left outer join and then update the on-clause for that relation. Since the criteria changes between queries I cannot fix the join criteria when specifying my object/table mappings. For example: tables: user, email relation:

[sqlalchemy] many-to-one question on delete

2009-09-14 Thread Steve Zatz
I have a simple foreign key relationship between a Task class and a Context class, where many Tasks can have the same Context. The default value for the Task foreign key context_id is 0. When I delete a Context, the Tasks with that context have their context_id automatically set to None and I

[sqlalchemy] Re: ORM and EXISTS?

2009-09-14 Thread Seppo11
On 11 Sep., 22:12, Conor conor.edward.da...@gmail.com wrote: This query will get you close to your desired SQL: q = session.query(ATable) q = q.filter(     sa.exists(         [1],         ((BTable.atable_id == ATable.id)           (CTable.cval.in_([foo, bar]))),        

[sqlalchemy] Re: How to instantiate objects of a class mapped against multiple tables?

2009-09-14 Thread bojanb
': metadata.create_all(db_engine) s=sessionmaker(bind=db_engine)() try: john = Person('John') peter = Employee('Peter', 'clerk') jack = Employee('Jack', 'manager') m1 = Meeting('20090914', peter, john) m2 = Meeting('20090915', peter, jack

[sqlalchemy] api.upgrade autocommit?

2009-09-14 Thread Suha Onay
Hi, I plan to use the migrate.versioning.api to manage the versions of the tables. But there are different repositories belonging to the modules of my project. Each module has its own repository but will refer to the tables of other modules. Is it possible? I have 2 different repositories: say

[sqlalchemy] getting data from primary keys

2009-09-14 Thread todd12
Hello SQLAlchemy Group, I've been trying to work out a way I can get the data from a table whose columns are primary keys. The challenge is, I don't know before hand which columns are primary keys since the code is to be run on different tables. I've figured out how to get the primary keys

[sqlalchemy] Re: How to instantiate objects of a class mapped against multiple tables?

2009-09-14 Thread Michael Bayer
=db_engine)() john = Employee('John', 'person') peter = Employee('Peter', 'clerk') jack = Employee('Jack', 'manager') m1 = Meeting('20090914', peter, john) m2 = Meeting('20090915', peter, jack) s.add_all([john, peter, jack, m1, m2]) s.commit() #We now want to print

[sqlalchemy] Re: getting data from primary keys

2009-09-14 Thread Mike Conley
If I understand this, you want to construct a query that returns the primary keys in an arbitrary table? Try this: key_cols = [c for c in table.primary_key.columns] session.query(*key_cols).all() --~--~-~--~~~---~--~~ You received this message because you are

[sqlalchemy] Re: How to instantiate objects of a class mapped against multiple tables?

2009-09-14 Thread bojanb
=db_engine)()     try:         john = Person('John')         peter = Employee('Peter', 'clerk')         jack = Employee('Jack', 'manager')         m1 = Meeting('20090914', peter, john)         m2 = Meeting('20090915', peter, jack)         s.add_all([john, peter, jack, m1, m2

[sqlalchemy] Re: How to instantiate objects of a class mapped against multiple tables?

2009-09-14 Thread Michael Bayer
: john = Person('John') peter = Employee('Peter', 'clerk') jack = Employee('Jack', 'manager') m1 = Meeting('20090914', peter, john) m2 = Meeting('20090915', peter, jack) s.add_all([john, peter, jack, m1, m2]) s.commit

[sqlalchemy] Self Join

2009-09-14 Thread Paulo Aquino
I have 2 tables 'Product' and 'ProductPrice'. I want to get all valid products, a product is valid if it has both a valid 'Selling' and 'Buying' ProductPrice type. A ProductPrice is valid if the valid_from date = date.today() and valid_to = date.today(). Product Table: id | sku | principal

[sqlalchemy] Mapping select to Read-only reporting class

2009-09-14 Thread Bryan
I want to abstract some ugly reporting SQL strings into a read-only object model. I have created an empty class, and then I map it to a select object that pulls some statistical information from the DB. The mapper is complaining that it can't assemble a primary key. I am only using this object

[sqlalchemy] Re: many-to-one question on delete

2009-09-14 Thread Michael Bayer
Steve Zatz wrote: I have a simple foreign key relationship between a Task class and a Context class, where many Tasks can have the same Context. The default value for the Task foreign key context_id is 0. When I delete a Context, the Tasks with that context have their context_id

[sqlalchemy] Re: 0.55, orm, varying relation join on criteria

2009-09-14 Thread Michael Bayer
me wrote: For certain orm queries with a 1-to-many relation i want to left outer join and then update the on-clause for that relation. Since the criteria changes between queries I cannot fix the join criteria when specifying my object/table mappings. For example: tables: user, email

[sqlalchemy] Re: Setting language for a db session

2009-09-14 Thread Michael Bayer
gizli wrote: From my understanding, some databases like MySQL does not support setting language for a particular DB session. Some others, such as Oracle, allows this. Is this ever considered in SA? If you are looking for an application wide setting, there is an open-ended API bywhich you

[sqlalchemy] Re: Self Join

2009-09-14 Thread Michael Bayer
Paulo Aquino wrote: I have 2 tables 'Product' and 'ProductPrice'. I want to get all valid products, a product is valid if it has both a valid 'Selling' and 'Buying' ProductPrice type. A ProductPrice is valid if the valid_from date = date.today() and valid_to = date.today(). Product Table:

[sqlalchemy] Re: api.upgrade autocommit?

2009-09-14 Thread Michael Bayer
Suha Onay wrote: Hi, I plan to use the migrate.versioning.api to manage the versions of the tables. But there are different repositories belonging to the modules of my project. Each module has its own repository but will refer to the tables of other modules. Is it possible? I have 2

[sqlalchemy] Re: Mapping select to Read-only reporting class

2009-09-14 Thread Michael Bayer
Bryan wrote: I want to abstract some ugly reporting SQL strings into a read-only object model. I have created an empty class, and then I map it to a select object that pulls some statistical information from the DB. The mapper is complaining that it can't assemble a primary key. I am only

[sqlalchemy] Re: geoalchemy and reflected tables

2009-09-14 Thread Christoph Böhme
Michael, Michael Bayer mike...@zzzcomputing.com schrieb: On Sep 13, 2009, at 7:01 AM, Christoph Böhme wrote: Hi all, I wonder if it is possible to reflect tables in a Postgres/PostGIS database with geoalchemy 0.1. The geoalchemy documentation only mentions delarative model

[sqlalchemy] Re: many-to-one question on delete

2009-09-14 Thread Steve Zatz
if you're using foreign keys correctly, that would imply there's an entity with an id of 0, and you'd attach that Context to each Task, replacing the old Context to be deleted. Michael, thanks for the usual thorough response. Yes, there is a Context entity with a unique (non-primary) id of