[sqlalchemy] Re: return type of relationship

2012-03-30 Thread lars van gemerden
Thanks, Is there a more direct way to do this for the Column return type as well? Now i have: @staticmethod def column(cls, name): for cl in cls.mro(): if hasattr(cl, '__table__'): for c in cl.__table__.c: if c.name == name: return

[sqlalchemy] datetime and engine

2012-03-30 Thread jo
Hi all, I found a difference between Oracle and PostgreSQL about datetime objects. Using the engine Oracle returns every date column as datetime.datetime while PostgreSQL returns it as datetime.date I have a table with a column data_inizio defined as DATE in table tariffa in my db. take a

[sqlalchemy] DuplicateKeyError exception

2012-03-30 Thread lestat
Hi! I use postgresql and I try create my exception DuplicateKeyError inheritanced from IntegrityError. I know that duplicate key in postgresql has code 23505 and I must catch with if err.orig.pgcode == '23505': ... How I can create this? I don't work with many exceptions, and don't find

[sqlalchemy] datetime and engine

2012-03-30 Thread shinriyo
hi jo Oracle and PostgreSQL are different. Oracle also have hour and minutes and second. If you want minutes and second on PostgresQL, you should use datetime. -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To view this discussion on the web

[sqlalchemy] Optimize and SqlAlchemy

2012-03-30 Thread Christian Démolis
Hi all, I have a very strange problem... I have an application which runs under SQL Alchemy. When my application is running and i launch OPTIMIZE TABLE in PhpMyAdmin, my process blocks showing this error Waiting for metadata lock When i close my application, the process unlocks. What happen in

[sqlalchemy] Re: help on SAWarning

2012-03-30 Thread lars van gemerden
Found another bug and the warning is gone; can't pinpoint why though ... On Mar 30, 1:03 am, lars van gemerden l...@rational-it.com wrote: OK, thanks, I still get the warning in some cases and i am still zooming in on the problem for a small test case. At least i have solved the problem of

Re: [sqlalchemy] datetime and engine

2012-03-30 Thread jo
shinriyo wrote: hi jo Oracle and PostgreSQL are different. Oracle also have hour and minutes and second. If you want minutes and second on PostgresQL, you should use datetime. Hi shinryo, I don't want hours and minutes. My problem is that I have a comparison in my code like this: if

[sqlalchemy] _deep_deannotate and aliased, joined tables

2012-03-30 Thread Christoph Rauch
Hello List, the problem I am facing is that _deep_deannotate, which is used in ColumnProperty.__init__, breaks the FROM clause of my select() object if this select() has a JOIN (either left or right, doesn't matter) as from_obj in it, _where the initial table is aliased_. To illustrate I'll

Re: [sqlalchemy] _deep_deannotate and aliased, joined tables

2012-03-30 Thread Michael Bayer
well the good news is that these cloning bugs, which have the property that each time I spend four hours fixing one I'm absolutely convinced it's the last (a process which began at least four years ago), are my highest priority since there are usually zero workarounds and also indicate there's

Re: [sqlalchemy] _deep_deannotate and aliased, joined tables

2012-03-30 Thread Michael Bayer
really great news, without even any coffee I came up with a patch for this one in less than 30 minutes. I need to create some tests, maybe try to figure out why this hasn't been seen more frequently and something should be committed today. It's on the ticket here:

Re: [sqlalchemy] DuplicateKeyError exception

2012-03-30 Thread Michael Bayer
if you want to rethrow DBAPI exceptions you'd need to catch it at some point. We don't have a hook where you can build in a try:/except: around executions right now so such a thing would need to be called externally to SQLAlchemy: def execute(connection, stmt): try: return

Re: [sqlalchemy] _deep_deannotate and aliased, joined tables

2012-03-30 Thread Christoph Rauch
Awesome! Thank you very much. :) Am Freitag, 30. März 2012 15:47:44 UTC+2 schrieb Michael Bayer: really great news, without even any coffee I came up with a patch for this one in less than 30 minutes. I need to create some tests, maybe try to figure out why this hasn't been seen more

Re: [sqlalchemy] DuplicateKeyError exception

2012-03-30 Thread lestat
if you want to rethrow DBAPI exceptions you'd need to catch it at some point. We don't have a hook where you can build in a try:/except: around executions right now so such a thing would need to be called externally to SQLAlchemy: Ok, thanks! -- You received this message because

Re: [sqlalchemy] datetime and engine

2012-03-30 Thread Mike Conley
The Oracle database only has one date type, and it includes time. If you require date only it is up to you to extract the date. Alternatively, if you really care about date only for all usage of that column, store it with a time of 00:00:00. On Mar 30, 2012 8:08 AM, jo jose.soa...@sferacarta.com

Re: [sqlalchemy] sqlalchemy supports INSERT INTO ... (SELECT .. ) ?

2012-03-30 Thread Michael Bayer
its not built in at the moment but there is a recipe in the docs for @compiles http://docs.sqlalchemy.org/en/latest/core/compiler.html#compiling-sub-elements-of-a-custom-expression-construct kind of amazing nobody's yet contributed a patch for this, I show people that recipe for a few years now

Re: [sqlalchemy] sqlalchemy supports INSERT INTO ... (SELECT .. ) ?

2012-03-30 Thread Kent Bower
Thanks for pointing me there. As an aside, the recipe would be more bulletproof if it specified the columns (order). Currently, it assumes sqlalchemy knows the order of the columns in the database, which it may not. Thanks again! On 3/30/2012 6:40 PM, Michael Bayer wrote: its not built in

Re: [sqlalchemy] sqlalchemy supports INSERT INTO ... (SELECT .. ) ?

2012-03-30 Thread Michael Bayer
so many great ideas for the eventual contributor ! ;) ideally it would be a method on insert() itself, table.insert().from(select([...])..., cols=('x', 'y', 'z')) or something like that. Maybe people have suggestions. On Mar 30, 2012, at 6:43 PM, Kent Bower wrote: Thanks for pointing me

Re: [sqlalchemy] sqlalchemy supports INSERT INTO ... (SELECT .. ) ?

2012-03-30 Thread Kent Bower
Yeah, I knew it was a hint... ;) So many great ideas, so little time. :( On 3/30/2012 6:58 PM, Michael Bayer wrote: so many great ideas for the eventual contributor ! ;) ideally it would be a method on insert() itself, table.insert().from(select([...])..., cols=('x', 'y', 'z')) or