[sqlalchemy] Re: Database migrations using declarative

2009-03-06 Thread Joril
On 5 Mar, 18:40, Michael Bayer mike...@zzzcomputing.com wrote: im finding it easiest to just autoload the tables in my migrate script.   That way there's no cut and paste the table def going on, you just load them as they are from the DB.  and the schema definition stays in the database for

[sqlalchemy] Re: Intermittent problem with mod_python

2009-03-06 Thread Michael Bayer
your classes and mappers should be created at the module level, so that once a module is imported, the mapper for that class is created just once along with the class itself. On Mar 6, 2009, at 7:42 AM, Marcin Krol wrote: Hello everyone, *From time to time* I get the following exception

[sqlalchemy] Re: SQLAlchemy Migrate

2009-03-06 Thread J. Cliff Dyer
On Thu, 2009-03-05 at 01:03 -0800, jarrod.ches...@gmail.com wrote: Hi All I'm writing a metadata based schema migration tool. As SQLAlchemy doesn't support much schema modification. I will implement a complete set of schema migration functions one way or another for several of the

[sqlalchemy] Joining on Two Databases on Same Database Server Using SQLSoup

2009-03-06 Thread noah.gift
Is it possible to do something like this with SQLSoup, or plain SQLAlchemy: SELECT p.Shot, s.fr_range_in, s.fr_range_out, s.cut_duration FROM Production.Production p JOIN Shots.Shots s on p.ShotID = s.shot_ID; I can intuitively figure out how that would work with SQLSoup because you pass in a

[sqlalchemy] Joining on Two Databases on Same Database Server Using SQLSoup

2009-03-06 Thread Noah Gift
Sorry if this is a double post, I think my last message barfed: I was wondering if this was theoretically possible with SqlSoup + SqlAlchemy. Here is the SQL: SELECT p.ShotID, s.shot_ID FROM Production.Production p JOIN Shots.Shots s on p.ShotID = s.shot_ID; I have two databases that live on

[sqlalchemy] Error due to MySQL-Python at 1.2.3?

2009-03-06 Thread Ben Cheng
Hi, I'm not sure is it a bug of SQLAlchemy or MySQL-Python, may some one advice or if you know any related tickets? When I'm using SQLAlchemy on MySQL-Python 1.2.3, it shows error on the following SQL when I call create_all: 19:05:33,895 INFO [sqlalchemy.engine.base.Engine.0x...a0f0] SHOW

[sqlalchemy] Re: SQLAlchemy Migrate

2009-03-06 Thread Stephen Emslie
It is always good to see some activity on this front. sqlalchemy-migrate seems to be a good idea that needs more activity. Perhaps try contributing to that project before branching. Any comment from the sqlalchemy-migrate developers? Stephen On Fri, Mar 6, 2009 at 3:13 PM, J. Cliff Dyer

[sqlalchemy] Re: Error due to MySQL-Python at 1.2.3?

2009-03-06 Thread Michael Bayer
looks like MySQL-Python changed their exception format again. here's our current code: try: rs = connection.execute(st) have = rs.rowcount 0 rs.close() return have except exc.SQLError, e:

[sqlalchemy] Thread safes transactions

2009-03-06 Thread Antonio Beamud Montero
Hi all: I'm using only sqlalchemy sql expression language, and in documentation appears that transactions objects are not thread safe.. Need I to implement a decorator like this? def transactional(fn): def transact(self, *args): c = self.engine.connect() lock.acquire()

[sqlalchemy] Re: Thread safes transactions

2009-03-06 Thread Michael Bayer
you dont need to define locking if you use each transaction in only a single thread.Below, you are acquiring a connection and a new transaction all locally defined within a function, so this code is threadsafe without the need for locks, provided the callable on the inside doesn't

[sqlalchemy] Re: Generating set of AND_ clauses dynamicly

2009-03-06 Thread az
or_( *list_of..) On Friday 06 March 2009 20:30:08 Tomasz Nazar wrote: Hi there, I have small issue and don't know how to solve .. I need to have this kind of query: q = dbsession().query(User). options(eagerload_all('lang_pairs.lang_a'), eagerload_all('lang_pairs.lang_a')).

[sqlalchemy] Generating set of AND_ clauses dynamicly

2009-03-06 Thread Tomasz Nazar
Hi there, I have small issue and don't know how to solve .. I need to have this kind of query: q = dbsession().query(User). options(eagerload_all('lang_pairs.lang_a'), eagerload_all('lang_pairs.lang_a')). join(['lang_pairs']). filter( or_(

[sqlalchemy] Re: Generating set of AND_ clauses dynamicly

2009-03-06 Thread Tomasz Nazar
That was quick genius :-) Thanks! On Fri, Mar 6, 2009 at 7:23 PM, a...@svilendobrev.com wrote: or_( *list_of..) On Friday 06 March 2009 20:30:08 Tomasz Nazar wrote: Hi there, I have small issue and don't know how to solve .. I need to have this kind of query: q =

[sqlalchemy] SqlSoup many-to-many relation causes insert into association table?

2009-03-06 Thread Scott Torborg
I am using SqlSoup to read from an MS SQL database and I'm having some issues building a many-to-many relation on the mapping. The database doesn't have any foreign keys, so I'm manually specifying the join conditions and keys. Specifying the relation returns without exceptions, but as soon as I

[sqlalchemy] Self referential declarative problem

2009-03-06 Thread Shawn Church
I'm trying to convert some classes from Elixir to declarative and am running into a problem defining a simple self-referencing definition. I've searched the archives and have tried several things but seem to be missing something: import sqlalchemy sqlalchemy.__version__ '0.5.2' from

[sqlalchemy] Re: SqlSoup many-to-many relation causes insert into association table?

2009-03-06 Thread Scott Torborg
Sorry for the trouble, after much stepping through source I figured it out. `secondary` needs to be a Table object, not a SqlSoup Entity. This fixes it: db.Products.relate('categories', db.Categories, secondary=db.ProductCategory._table, _table is your friend!

[sqlalchemy] Re: Self referential declarative problem

2009-03-06 Thread Michael Bayer
On Mar 6, 2009, at 6:14 PM, Shawn Church wrote: But setting the User.modified_by relation does not work: user.modified_by = user the key here is that you're setting modified_by to the parent, which means you are creating a row that's dependent on itself. This will work on UPDATE but

[sqlalchemy] Re: Self referential declarative problem

2009-03-06 Thread Shawn Church
On Fri, Mar 6, 2009 at 3:43 PM, Michael Bayer mike...@zzzcomputing.comwrote: On Mar 6, 2009, at 6:14 PM, Shawn Church wrote: But setting the User.modified_by relation does not work: user.modified_by = user the key here is that you're setting modified_by to the parent, which means

[sqlalchemy] Re: Self referential declarative problem

2009-03-06 Thread Michael Bayer
On Mar 6, 2009, at 7:04 PM, Shawn Church wrote: On Fri, Mar 6, 2009 at 3:43 PM, Michael Bayer mike...@zzzcomputing.com wrote: On Mar 6, 2009, at 6:14 PM, Shawn Church wrote: But setting the User.modified_by relation does not work: user.modified_by = user the key here is that

[sqlalchemy] Re: Self referential declarative problem

2009-03-06 Thread Shawn Church
On Fri, Mar 6, 2009 at 4:36 PM, Michael Bayer mike...@zzzcomputing.comwrote: uh yeah it is. the sync of the primary key to the foreign key happens after the parent object is updated. but the child is also the parent, so the flush completes without ever getting to the child. if you set

[sqlalchemy] Surfacing table and column-level comments to Python classes as docstrings

2009-03-06 Thread phrrn...@googlemail.com
I have some metadata on table and some of the columns and would like to surface these as docstrings on the mapped class and columns. If table foo has columns i, j, k with comments 'apple', 'banana', 'pear', respectively, and the table is mapped via class Foo then I would like the programmer to