[sqlalchemy] Dabo ReportDesigner/Writer

2013-06-04 Thread Werner
Hi, I am looking at Dabo's ReportDesigner/Writer to do reporting (looked at others like PythonReports and Geraldo) but both have problems with large text blobs. It wants the data as: Dabo's reportwriter wants dataset-like structures, which is a sequence (list, tuple) of mappings (dict),

[sqlalchemy] EXTRACT() not working as expected in PostgreSQL with TIMESTAMP WITH TIMEZONE

2013-06-04 Thread Martijn van Oosterhout
I have just upgraded sqlalchemy and am running some tests on some old code and getting some very strange results. I have a table with a column defined as TIMESTAMP WITH TIMEZONE: test_table = Table('test', metadata, Column('id', Integer, primary_key=True), Column('data', UnicodeText,

[sqlalchemy] Re: EXTRACT() not working as expected in PostgreSQL with TIMESTAMP WITH TIMEZONE

2013-06-04 Thread Martijn van Oosterhout
For the record and for other people running into the same problem, here's a workaround that kills the cast by wrapping the column in a function that does nothing: session.query(extract('epoch', func.timestamptz(database.TestTable.ts))) This of course will only work until sqlalchemy learns

Re: [sqlalchemy] [Q][SA 0.7.9] yield_per() vs. joinedload() and subqueryload()

2013-06-04 Thread Michael Bayer
On Jun 4, 2013, at 8:18 AM, Ladislav Lenart lenart...@volny.cz wrote: Hello. I have a hard time to understand the following comment for Query.yield_per(): Yield only ``count`` rows at a time. WARNING: use this method with caution; if the same instance is present in

Re: [sqlalchemy] nested inheritance / polymorphic relationships

2013-06-04 Thread Michael Bayer
On Jun 4, 2013, at 1:55 AM, Amir Elaguizy aelag...@gmail.com wrote: Hi there, I have a tree that looks like this, reflected via polymorphic inheritance: what do we mean reflected here, are you reflecting tables from the database, that is,

[sqlalchemy] Changing a value linked with a one-to-one relationship

2013-06-04 Thread Etienne Rouxel
Hello I would like to change a value in a one-to-one relationship but I cannot because of some actions that SQLAlchemy try to do, and I don't know why. Here is my simplified code : # -*- coding: utf-8 -*- from sqlalchemy import * from sqlalchemy.orm import * from sqlalchemy.ext.declarative

Re: [sqlalchemy] [Q][SA 0.7.9] yield_per() vs. joinedload() and subqueryload()

2013-06-04 Thread Ladislav Lenart
Hello. assuming cls.foo is a many-to-one, it will produce the correct result, but will be far worse in terms of memory and performance, as the subqueryload() call will be invoked for each distinct batch of 50 rows, across the *full* result set. So if your result has 1000 rows, and the

Re: [sqlalchemy] nested inheritance / polymorphic relationships

2013-06-04 Thread Amir Elaguizy
I didn't intend to use the word reflected in the Programming sense, I meant in the traditional sense: is represented by. That sentence was confusing, sorry! I was saying class B, C, and D are all defined using that same pattern. They each have their own class. Amir On Tuesday, June 4, 2013,

Re: [sqlalchemy] EXTRACT() not working as expected in PostgreSQL with TIMESTAMP WITH TIMEZONE

2013-06-04 Thread Michael Bayer
On Jun 4, 2013, at 4:53 AM, Martijn van Oosterhout klep...@gmail.com wrote: I have just upgraded sqlalchemy and am running some tests on some old code and getting some very strange results. I have a table with a column defined as TIMESTAMP WITH TIMEZONE: test_table = Table('test',

Re: [sqlalchemy] Changing a value linked with a one-to-one relationship

2013-06-04 Thread Michael Bayer
On Jun 4, 2013, at 10:38 AM, Etienne Rouxel rouxel.etie...@gmail.com wrote: and then: UPDATE botany.plant SET taxon_id=NULL WHERE botany.plant.id = -2147483643 which fails because NULL is not allowed for taxon_id. So, why do not SQLAlchemy just output this instead? UPDATE

Re: [sqlalchemy] [Q][SA 0.7.9] yield_per() vs. joinedload() and subqueryload()

2013-06-04 Thread Michael Bayer
On Jun 4, 2013, at 10:45 AM, Ladislav Lenart lenart...@volny.cz wrote: Hello. assuming cls.foo is a many-to-one, it will produce the correct result, but will be far worse in terms of memory and performance, as the subqueryload() call will be invoked for each distinct batch of 50 rows,

Re: [sqlalchemy] [Q][SA 0.7.9] yield_per() vs. joinedload() and subqueryload()

2013-06-04 Thread Ladislav Lenart
Hello. You will then get the wrong results. The docstring tries to explain this - a joinedload uses a JOIN. For each cls instance, there are many rows, one for each bar. If you cut off the results in the middle of populating that collection, the collection is incomplete, you'll see the

Re: [sqlalchemy] [Q][SA 0.7.9] yield_per() vs. joinedload() and subqueryload()

2013-06-04 Thread Michael Bayer
On Jun 4, 2013, at 11:41 AM, Ladislav Lenart lenart...@volny.cz wrote: Hello. You will then get the wrong results. The docstring tries to explain this - a joinedload uses a JOIN. For each cls instance, there are many rows, one for each bar. If you cut off the results in the middle of

Re: [sqlalchemy] [Q][SA 0.7.9] yield_per() vs. joinedload() and subqueryload()

2013-06-04 Thread Ladislav Lenart
Hello. OK, but with yield_per() you want to use eagerloading also, so yield_per() not fast enough either, I guess No. I use yield_per() on complex queries with join(), filter() and both joinedload() and subqueryload(). It is possible that they sometimes returns wrong results because of

Re: [sqlalchemy] Changing a value linked with a one-to-one relationship

2013-06-04 Thread Michael Bayer
On Jun 4, 2013, at 11:15 AM, Michael Bayer mike...@zzzcomputing.com wrote: There seems to be some unfortunate effect going on, as the issue of backrefs loading collections like this was long ago resolved to defer that activity, but it appears that when uselist=False is present, this logic

Re: [sqlalchemy] [Q][SA 0.7.9] yield_per() vs. joinedload() and subqueryload()

2013-06-04 Thread Michael Bayer
On Jun 4, 2013, at 12:28 PM, Ladislav Lenart lenart...@volny.cz wrote: Absolutely, you should do whatever you have to in order to get the range you want, in fact the recipe even says this... Ok. What I want to do is basically the following: * Suppose a complex query q with join(...),

Re: [sqlalchemy] [Q][SA 0.7.9] yield_per() vs. joinedload() and subqueryload()

2013-06-04 Thread Ladislav Lenart
On 4.6.2013 18:49, Michael Bayer wrote: On Jun 4, 2013, at 12:28 PM, Ladislav Lenart lenart...@volny.cz wrote: Absolutely, you should do whatever you have to in order to get the range you want, in fact the recipe even says this... Ok. What I want to do is basically the following: *

[sqlalchemy] Re: nested inheritance / polymorphic relationships

2013-06-04 Thread Amir Elaguizy
Just to tie this off, I ended up flattening the tree so it looks like: A / | \\ B C E F D is now gone and the functionality it provided is in the children (E F). I'll probably make the common parts a mixin or something. Unfortunate but I couldn't spend more time on

Re: [sqlalchemy] Query and compiled_cache

2013-06-04 Thread Claudio Freire
On Sun, Jun 2, 2013 at 9:41 PM, Claudio Freire klaussfre...@gmail.comwrote: So the whole thing is rolled up into the named thing I referred to also, so that there's no need to keep a Query object hanging around, when we say bake() we're really just referring to a position in the code

Re: [sqlalchemy] Reliable way to read comments from database schema

2013-06-04 Thread Michael Bayer
There's a long standing ticket to add support for comments, at least at the DDL level. I don't think anyone has looked into what level of support we get from the various backends as far as reflection. So its something the library has room for, but it's an open item for now. The

Re: [sqlalchemy] Reliable way to read comments from database schema

2013-06-04 Thread Mariano Mara
On 06/04/2013 10:46 PM, Michael Bayer wrote: There's a long standing ticket to add support for comments, at least at the DDL level. I don't think anyone has looked into what level of support we get from the various backends as far as reflection. So its something the library has room for,

Re: [sqlalchemy] Reliable way to read comments from database schema

2013-06-04 Thread Warwick Prince
On 06/04/2013 10:46 PM, Michael Bayer wrote: There's a long standing ticket to add support for comments, at least at the DDL level. I don't think anyone has looked into what level of support we get from the various backends as far as reflection. So its something the library has room

Re: [sqlalchemy] nested inheritance / polymorphic relationships

2013-06-04 Thread Ladislav Lenart
Hello. It seems like I have to choose, D can either be a polymorphic child or it can be a parent - it can't be both. Do I have any options here? I am almost sure you are correct. This is not possible in SA so you have to flatten your hierarchy. I don't know about experiences with