[sqlalchemy] Re: Schema and database migration: how to diff?

2008-06-06 Thread az
On Friday 06 June 2008 02:06:23 Yannick Gingras wrote: [EMAIL PROTECTED] writes: see dbcook.misc.metadata.diff.py as an attempt to do this over 2 metadata's. svn co https://dbcook.svn.sourceforge.net/svnroot/dbcook/trunk/dbcook/mi sc/metadata It works pretty well. How about a small

[sqlalchemy] Re: out of range / locate column / lost connection

2008-06-06 Thread az
first two mean the result of the query is empty. On Friday 06 June 2008 01:49:23 braydon fuller wrote: I am having some database problems (attached below), any recommendations to either recover from or fix these from happening? I am not sure why it would work OK at first, and then at some

[sqlalchemy] how to cancel order_by on a query?

2008-06-06 Thread az
i have a premade query with some order_by but i want to replace the order_by. any legal way to do it? q=q.order_by(a,b,c) seems to only add a,b,c to existing order_by; q=q.order_by() and q=q.order_by(None) do nothing --~--~-~--~~~---~--~~ You received this

[sqlalchemy] Sharded query stops working with 0.4.6

2008-06-06 Thread Andrew Stromnov
After upgrading from 0.4.5 to 0.4.6 Session.execute(query, shard_id=shard_id), where Session is ShardedSession, throws exception: File '/var/lib/python-support/python2.5/sqlalchemy/orm/scoping.py', line 98 in do return getattr(self.registry(), name)(*args, **kwargs) TypeError: execute() got an

[sqlalchemy] Re: how to cancel order_by on a query?

2008-06-06 Thread Michael Bayer
On Jun 6, 2008, at 3:27 AM, [EMAIL PROTECTED] wrote: i have a premade query with some order_by but i want to replace the order_by. any legal way to do it? q=q.order_by(a,b,c) seems to only add a,b,c to existing order_by; q=q.order_by() and q=q.order_by(None) do nothing order_by(None)

[sqlalchemy] Re: Sharded query stops working with 0.4.6

2008-06-06 Thread Michael Bayer
can you add a trac ticket and use Session.connection(shard_id=).execute() for now...thanks On Jun 6, 2008, at 6:53 AM, Andrew Stromnov wrote: After upgrading from 0.4.5 to 0.4.6 Session.execute(query, shard_id=shard_id), where Session is ShardedSession, throws exception: File

[sqlalchemy] Re: how to cancel order_by on a query?

2008-06-06 Thread az
On Friday 06 June 2008 17:09:02 Michael Bayer wrote: On Jun 6, 2008, at 3:27 AM, [EMAIL PROTECTED] wrote: i have a premade query with some order_by but i want to replace the order_by. any legal way to do it? q=q.order_by(a,b,c) seems to only add a,b,c to existing order_by; q=q.order_by()

[sqlalchemy] Custom Comparator with order_by

2008-06-06 Thread Martin Pengelly-Phillips
Hi there, Quick question - is it possible to get a custom comparator to work with order_by? At present my code based on SA/examples/vertical/dictlike- polymorphic.py raises a NotImplementedError when attempting to use the value in an order_by statement. ta, Martin --- q =

[sqlalchemy] Create polymorphic mapped instance from type discriminator

2008-06-06 Thread Rick Morrison
Is there an API-stable way to create a polymorphic instance from only the type discriminator key? I've got a case where I need to create a mapped instance from some JSON data that contains the type discriminator, but I'd rather get the (key -- mapped class) from the sqla map and not maintain my

[sqlalchemy] Orphan error

2008-06-06 Thread Brad Wells
With the following simplified setup I receive the following error: FlushError: instance erp.model.financial.TransactionOffset object at 0x0203CC90 is an unsaved, pending instance and is an orphan (is not attached to any parent 'Transaction' instance via that classes' 'offsets' attribute) When

[sqlalchemy] Re: Optimizing a slow query

2008-06-06 Thread beewee
Hi, I merged the two tables into a single one, changed the mapping but the query still needs more than 10 seconds :/ That's how EXPLAIN looks like now: http://paste.pocoo.org/show/63542/ I think the problem is this one: | 2 | DERIVED | forum_post | ALL| forum_post_topic_id

[sqlalchemy] Re: Create polymorphic mapped instance from type discriminator

2008-06-06 Thread Bobby Impollonia
The mapper for the base class has a property called polymorphic_map which is a dictionary whose keys are the discriminator values and whose values are the mappers of the associated classes (you can get from there to the actual class via the mapper's class_ property). I can't speak to whether

[sqlalchemy] Re: Orphan error

2008-06-06 Thread Michael Bayer
offsets and transaction need to be combined into one relation with a backref() so that an attribute set on one side generates a collection add on the other. Backrefs are described in the ORM tutorial and mapper configuration docs, to send arguments to a backref use the backref() function

[sqlalchemy] reading from one database and writing to another

2008-06-06 Thread qhfgva
We have (what I think of as) a moderately complicated database configuration and I'm hoping there will be a way to configure sqlalchemy to deal with it. The basic scenario is like this: There are N mysql servers in different geographical regions that are all replicating against one master. In

[sqlalchemy] Re: reading from one database and writing to another

2008-06-06 Thread Michael Bayer
On Jun 6, 2008, at 2:29 PM, qhfgva wrote: We have (what I think of as) a moderately complicated database configuration and I'm hoping there will be a way to configure sqlalchemy to deal with it. The basic scenario is like this: There are N mysql servers in different geographical regions

[sqlalchemy] Simple example of Session usage in multi threaded context

2008-06-06 Thread Venkatesh
Hello, I'm trying to use SQLAlchemy for my Python project which is a multi- threaded application. While I've had good success in performing CRUD operations with a single thread, I'm having a lot of trouble when I start using multiple threads. Can anybody give a simple example of using the

[sqlalchemy] PostgreSQL and inserting

2008-06-06 Thread Cliff Wells
Just an FYI, in PostgreSQL 8.2.4 they added a new feature returning which can be used to avoid the need for an additional query (to get the value of serial columns) when inserting records: test=# create table foo ( id serial primary key not null, name text ); test=# insert into foo ( name )

[sqlalchemy] Re: PostgreSQL and inserting

2008-06-06 Thread Michael Bayer
On Jun 6, 2008, at 9:11 PM, Cliff Wells wrote: Just an FYI, in PostgreSQL 8.2.4 they added a new feature returning which can be used to avoid the need for an additional query (to get the value of serial columns) when inserting records: test=# create table foo ( id serial primary key