[sqlalchemy] Re: @compiles ignores inheritance

2010-03-30 Thread Tobias
Great! Thanks a lot, Michael. On Mar 30, 4:42 pm, "Michael Bayer" wrote: > Tobias wrote: > > Hi, > > > So I thought I could write just one method, that is annotated with > > @compiles(__base_function), but this does not work. I have to write a > > method for each class that inherits from __base

Re: [sqlalchemy] best-practices question

2010-03-30 Thread Taavi Burns
Jon Nelson wrote: > Let's say I have a database with hundreds or even thousands of tables. Sure you didn't mean "hundreds OF thousands"? :) On Tue, Mar 30, 2010 at 2:09 PM, Michael Bayer wrote: > def map_a_table(tablename): >    table = Table(tablename, metadata, >         ...put the standard s

Re: [sqlalchemy] Sharding with _BindParamClause

2010-03-30 Thread Michael Bayer
George V. Reilly wrote: > We're using SQLAlchemy sharding to partition accounts across a couple > of databases. We want to add more partitions, but first we need to > eliminate some unnecessary cross-partition queries. > > class FindShardableId(sqlalchemy.sql.ClauseVisitor): > def __ini

[sqlalchemy] Re: add_column does not correlate with aliased table.

2010-03-30 Thread Kalium
On Mar 30, 10:54 pm, Michael Bayer wrote: > On Mar 30, 2010, at 2:47 AM, Kalium wrote: > > > > > Hi, > > I've had a look through the docs and a quick look through the forum > > here, and haven't been able to solve my problem. I'm using 0.4 > > > The following works as expected. > > > q = > > Sys

[sqlalchemy] Sharding with _BindParamClause

2010-03-30 Thread George V. Reilly
We're using SQLAlchemy sharding to partition accounts across a couple of databases. We want to add more partitions, but first we need to eliminate some unnecessary cross-partition queries. class FindShardableId(sqlalchemy.sql.ClauseVisitor): def __init__(self, ids, key_fields, get_shar

[sqlalchemy] Re: Restricting a delete based on a many-to-many mapping.

2010-03-30 Thread Rich
On Mar 29, 6:15 pm, Michael Bayer wrote: > you want the delete to fail if there *are* users associated or if there are > *not* ?    for the "raise an error if users exist", the most efficient and > generic way is to ensure the foreign key on UserGroup is not nullable and > "delete" cascade is

Re: [sqlalchemy] best-practices question

2010-03-30 Thread Michael Bayer
Jon Nelson wrote: > Let's say I have a database with hundreds or even thousands of tables. > The table structure for this set of tables is *exactly* the same. > Furthermore, let's say the name of each table is predictable. > For example, something like: > > tablename_2010_03_05 > > What I'd like to

[sqlalchemy] best-practices question

2010-03-30 Thread Jon Nelson
Let's say I have a database with hundreds or even thousands of tables. The table structure for this set of tables is *exactly* the same. Furthermore, let's say the name of each table is predictable. For example, something like: tablename_2010_03_05 What I'd like to know is how to best manage maki

Re: [sqlalchemy] PyODBCConnector dbapi question

2010-03-30 Thread Michael Bayer
Bo Shi wrote: >> pep 249 specifies "list of tuples" for fetchmany() and fetchall() > > Hrm, pep-249 seems to only specify "sequence" and "sequence of > sequences" for the fetch*() functions, specifying list of tuples only > as one possible example. Perhaps the C implementation of RowProxy is > bei

Re: [sqlalchemy] PyODBCConnector dbapi question

2010-03-30 Thread Bo Shi
> pep 249 specifies "list of tuples" for fetchmany() and fetchall() Hrm, pep-249 seems to only specify "sequence" and "sequence of sequences" for the fetch*() functions, specifying list of tuples only as one possible example. Perhaps the C implementation of RowProxy is being too strict here? I'm

[sqlalchemy] Re: Column type in select w/ if condition

2010-03-30 Thread Bryan
That worked, thanks. On Mar 30, 7:40 am, Mariano Mara wrote: > Excerpts from Bryan's message of Tue Mar 30 11:27:57 -0300 2010: > > > The underlying column returns a Decimal object when queried regularly, > > and when summed as follows: > > > select([ mytable.c.hours ]) > > >>>Decimal("1.0") > >

Re: [sqlalchemy] @compiles ignores inheritance

2010-03-30 Thread Michael Bayer
Tobias wrote: > Hi, > > > So I thought I could write just one method, that is annotated with > @compiles(__base_function), but this does not work. I have to write a > method for each class that inherits from __base_function: > > @compiles(wkt) > def compile_wkt(element, compiler, **kw): > retur

Re: [sqlalchemy] Column type in select w/ if condition

2010-03-30 Thread Mariano Mara
Excerpts from Bryan's message of Tue Mar 30 11:27:57 -0300 2010: > The underlying column returns a Decimal object when queried regularly, > and when summed as follows: > > select([ mytable.c.hours ]) > >>>Decimal("1.0") > select([ func.sum(mytable.c.hours) ]) > >>>Decimal("1.0") > > ...but when I

Re: [sqlalchemy] identifier is too long

2010-03-30 Thread jo
I see, thank you, Mariano. j Mariano Mara wrote: Excerpts from jo's message of Tue Mar 30 03:25:18 -0300 2010: Hi all, I have some troubles creating my db schema with Oracle. The problem is on this column: Column('cod_caratteristica_rischio', Unicode(10), index=True, nullable=False) It

[sqlalchemy] Column type in select w/ if condition

2010-03-30 Thread Bryan
The underlying column returns a Decimal object when queried regularly, and when summed as follows: select([ mytable.c.hours ]) >>>Decimal("1.0") select([ func.sum(mytable.c.hours) ]) >>>Decimal("1.0") ...but when I sum it w/ an if statement, it returns a float: select([ func.sum(func.if_(True, m

Re: [sqlalchemy] add_column does not correlate with aliased table.

2010-03-30 Thread Michael Bayer
On Mar 30, 2010, at 2:47 AM, Kalium wrote: > Hi, > I've had a look through the docs and a quick look through the forum > here, and haven't been able to solve my problem. I'm using 0.4 > > The following works as expected. > > q = > System.query().join('activity').group_by(model.System.id).add_co

Re: [sqlalchemy] identifier is too long

2010-03-30 Thread Mariano Mara
Excerpts from jo's message of Tue Mar 30 03:25:18 -0300 2010: > Hi all, > > I have some troubles creating my db schema with Oracle. The problem is > on this column: > > Column('cod_caratteristica_rischio', Unicode(10), index=True, > nullable=False) > > It works fine in PostgreSQL but when I tr