[sqlalchemy] SQLAlchemy Migrate

2009-03-05 Thread jarrod.ches...@gmail.com
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 supported databases. My question is, Where should these function

[sqlalchemy] Re: miss for postgres_from in update() :(

2009-03-05 Thread sector119
I create a small (4 lines) patch for databases/postgres.py def _append_from(self, text, stmt): return text.replace(' WHERE', ' FROM ' + string.join([table.name for table in stmt.kwargs['postgres_from']], ', ') + ' WHERE') def visit_update(self, update_stmt): text = super(PGCompiler,

[sqlalchemy] Re: SQLAlchemy Migrate

2009-03-05 Thread Lawrence Oluyede
On Thu, Mar 5, 2009 at 10:03 AM, jarrod.ches...@gmail.com jarrod.ches...@gmail.com wrote: I'm writing a metadata based schema migration tool. Keep in mind there are some other projects like http://code.google.com/p/sqlalchemy-migrate/ HTH -- Lawrence Oluyede [eng] http://oluyede.org -

[sqlalchemy] Re: miss for postgres_from in update() :(

2009-03-05 Thread Michael Bayer
visit_update() would have to be rewritten in the base compiler to support addition of extra components. On Mar 5, 2009, at 5:05 AM, sector119 wrote: I create a small (4 lines) patch for databases/postgres.py def _append_from(self, text, stmt): return text.replace(' WHERE', ' FROM '

[sqlalchemy] Complex joins (newbie alert)

2009-03-05 Thread Marcin Krol
Hello everyone, So I've got this piece of code: selectexpr = session.query(Host, Architecture, OS_Kind) selectexpr = selectexpr.filter(Host.Architecture_id==Architecture.id).filter(Architecture.Architecture=='IBM xSeries') selectexpr =

[sqlalchemy] recursive sql

2009-03-05 Thread che
hi alchemysts, as of end of march 2009 there will be version of PostgreSQL (hopefully, finally;) that will support recursive sqls (WITH RECURSIVE...) and there are also at least 4 other main SQL that already support it (DB2, MSSQL, Firebird, Oracle (syntax diff)), do you have plans for adding

[sqlalchemy] Re: recursive sql

2009-03-05 Thread Michael Bayer
its something we should take on at some point, yes, but no concrete plans have been made.each DB has a different take on it and the common set of functionality would need to be extracted. che wrote: hi alchemysts, as of end of march 2009 there will be version of PostgreSQL (hopefully,

[sqlalchemy] Modifiable collections on a many-to-many, same table mapping

2009-03-05 Thread Kevin Dangoor
I have a many-to-many mapping that joins against a single table. The relation works fine, except when I try to add a new mapping via the list created by relation(). To make things extra interesting, I'm using declarative (which I really like, actually, because it maps in a fairly straightforward

[sqlalchemy] Database migrations using declarative

2009-03-05 Thread Joril
Hi everyone! I'm looking for a way to handle database migrations/upgrades and found projects such as sqlalchemy-migrate and mikuru.. My understanding is that those projects expect the model to be in NON-declarative form, that is, with users_table = Table(...) and the like.. But what if my program

[sqlalchemy] Re: Database migrations using declarative

2009-03-05 Thread Kevin Dangoor
On Thu, Mar 5, 2009 at 12:17 PM, Joril jor...@gmail.com wrote: I'm looking for a way to handle database migrations/upgrades and found projects such as sqlalchemy-migrate and mikuru.. My understanding is that those projects expect the model to be in NON-declarative form, that is, with

[sqlalchemy] Re: Modifiable collections on a many-to-many, same table mapping

2009-03-05 Thread az
as i see u have normal mapping for the Connection, and still use it as secondary table; once i did use such (semi-legal?:) thing but the relation was readonly. try not giving secondary* args ? On Thursday 05 March 2009 18:37, Kevin Dangoor wrote: I have a many-to-many mapping that joins

[sqlalchemy] Re: Modifiable collections on a many-to-many, same table mapping

2009-03-05 Thread Michael Bayer
make those m2m relations(), and any other relation that doesn't represent a single path of persistence, viewonly=True . its all the three ways to see the same thing going on, minus viewonly=True means three ways to persist the same thing, leading to errors like that. Kevin Dangoor wrote: I

[sqlalchemy] Re: Database migrations using declarative

2009-03-05 Thread Michael Bayer
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 those who get bent out of shape about that. problem solved. the

[sqlalchemy] Re: Sybase DB-API driver uses @foo for placeholder names and expect parameter dict keys to be similarly named

2009-03-05 Thread phrrn...@googlemail.com
The problem with the connection being returned to the pool was due to executing the SET IDENTITY_INSERT statement on the *cursor* rather than the *connection*. The documentation states that the connection will be returned to the pool when a statement is executed on it that doesn't return any

[sqlalchemy] Could not locate any equated, locally mapped column pairs for primaryjoin condition

2009-03-05 Thread Alex Marandon
Hi there, Could someone explain me a bit what this error message means and what could be causing it: sqlalchemy.exc.ArgumentError: Could not locate any equated, locally mapped column pairs for primaryjoin condition 'pages.author_id = users.id' on relation Page.author. For more relaxed rules on

[sqlalchemy] Re: Modifiable collections on a many-to-many, same table mapping

2009-03-05 Thread Kevin Dangoor
On Thu, Mar 5, 2009 at 12:38 PM, Michael Bayer mike...@zzzcomputing.com wrote: make those m2m relations(), and any other relation that doesn't represent a single path of persistence, viewonly=True .   its all the three ways to see the same thing going on, minus viewonly=True means three ways

[sqlalchemy] Re: SQLAlchemy Migrate

2009-03-05 Thread jarrod.ches...@gmail.com
Yes, Option 2 - However, From the example documentation, Its doesn't implement everything. Although its most of the way there - So option 2 is looking good to me. On Mar 6, 1:23 am, Lawrence Oluyede l.oluy...@gmail.com wrote: On Thu, Mar 5, 2009 at 10:03 AM, jarrod.ches...@gmail.com

[sqlalchemy] Re: Could not locate any equated, locally mapped column pairs for primaryjoin condition

2009-03-05 Thread Michael Bayer
if there's an incompatible foreign_keys collection specified that can also lead to this error. the Page and User classes must map the author_id and id columns normally as well, i.e. no exclude_columns or relations getting in the way. Alex Marandon wrote: Hi there, Could someone explain me

[sqlalchemy] Re: Supporting fully-qualified table names and cross-database references in Sybase and SQL Server?

2009-03-05 Thread Michael Bayer
phrrn...@googlemail.com wrote: Sybase (and SQL Server) support cross-database JOINs (Sybase even supports cross-database foreign-key constraints). There are four components to an object identifier: 1 = Object name 2 = Schema name 3 = Database name 4 = Server name the dataserver,

[sqlalchemy] Re: Using sqlalchemy in twisted.

2009-03-05 Thread Jeff FW
Don't use scoped_session--you'll run into problems no matter what you do. I'm using Perspective Broker from Twisted with SQLAlchemy. I make sure to create and commit/rollback a session for *every* PB request. It works perfectly, and that's the only way I was really able to get it to work in

[sqlalchemy] Using a SQL function w/ strange syntax as default

2009-03-05 Thread Bryan
I want to use MySQL's uuid() function to create default values for a column. I need to convert the output of uuid() to utf-8 however, so the full function in SQL looks like this: CONVERT(UUID() USING utf8) I can't set this as a column default using the func.function() syntax, because python

[sqlalchemy] Re: Supporting fully-qualified table names and cross-database references in Sybase and SQL Server?

2009-03-05 Thread phrrn...@googlemail.com
OK. If it might be as easy as that, I will have a go and see how well it works. pjjH On Mar 5, 4:31 pm, Michael Bayer mike...@zzzcomputing.com wrote: phrrn...@googlemail.com wrote: Sybase (and SQL Server) support cross-database JOINs (Sybase even supports cross-database foreign-key

[sqlalchemy] Re: Using a SQL function w/ strange syntax as default

2009-03-05 Thread Michael Bayer
how about func.convert(literal_column(UUID() USING utf8)) Bryan wrote: I want to use MySQL's uuid() function to create default values for a column. I need to convert the output of uuid() to utf-8 however, so the full function in SQL looks like this: CONVERT(UUID() USING utf8) I can't