[sqlalchemy] 0.8.x - can't get correlation to work with nested subquery in column property

2013-06-05 Thread Yap Sok Ann
I am getting stuck trying to upgrade to 0.8.x, as I can't get correlation to work with nested subquery in column property. Here's a slightly absurd example for illustration: from sqlalchemy import * from sqlalchemy.orm import * from sqlalchemy.ext.declarative import declarative_base Base =

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

2013-06-05 Thread Etienne Rouxel
Hello Michael Sorry for the late reply. So, below is my full stack trace: Traceback (most recent call last): File /Users/foobar/Developpement/nursery_project/applications/nurserydb/utils_scripts/test2.py, line 64, in module plant.taxon = taxon_new # triggers an IntegrityError File

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

2013-06-05 Thread Ladislav Lenart
Hello. I have one more question about my approach to WindowedRangeQuery: * Suppose a complex query q with join(...), filter(...) and options(...). * I need to create q2 from q such that: * It has no options. * Can I reset the options with q = q.options(None)? * It has select with the

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

2013-06-05 Thread Ladislav Lenart
Hello. I've tried an experiment to verify that yield_per() with subqueryload() behaves as badly as you described, but according to my practical observation, it issues ONE subqueryload() and everything behaves as I would expect. It emits two SELECTs, one to fetch the objects and the second one to

[sqlalchemy] Specifying foreign_keys and remote_side in self-referential many-to-many relationship

2013-06-05 Thread Hong Minhee
Hi, I have two tables User and Following, and User has two relationships followings and followers. It’s so typical, and next I want is readonly relationship to union of followings and followers. I tried like: friends = relationship( 'User', collection_class=set,

[sqlalchemy] Re: Specifying foreign_keys and remote_side in self-referential many-to-many relationship

2013-06-05 Thread Hong Minhee
It seems I found the most close solution: http://stackoverflow.com/a/9119764/383405 I haven’t been aware that secondary can take select() query as well. Might there be another way to achieve the same by any chance? On Jun 5, 2013, at 9:27 PM, Hong Minhee min...@dahlia.kr wrote: Hi, I

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

2013-06-05 Thread Ladislav Lenart
Hello. One more note. I've just tried the below experiment with joinedload() instead of subqueryload() and that does NOT work just as you expected. One contact is returned several times and the first occurrences have incomplete phones. However my experiments with subqueryload() suggest that it

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

2013-06-05 Thread Michael Bayer
the Query emitted by subqueryload does not use yield_per. so if your total result set is 1000 rows, and the total rows represented by all the collections is 1, the first time that query is emitted, 1 rows will be fully loaded and processed into memory at once. This would occur

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

2013-06-05 Thread Michael Bayer
On Jun 5, 2013, at 3:52 AM, Etienne Rouxel rouxel.etie...@gmail.com wrote: However, I get confused by SQLAlchemy trying to set taxon_id to NULL or even worse, please keep in mind that this was within an autoflush, in between where the state of your object graph in memory was complete. If

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

2013-06-05 Thread Ladislav Lenart
Ok, so yield_per() is useless when subqueryload() is used. Thank you, Ladislav Lenart On 5.6.2013 16:27, Michael Bayer wrote: the Query emitted by subqueryload does not use yield_per. so if your total result set is 1000 rows, and the total rows represented by all the collections is

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

2013-06-05 Thread Mariano Mara
On 06/04/2013 11:22 PM, Warwick Prince wrote: 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

Re: [sqlalchemy] Including counts in query results

2013-06-05 Thread Charlie Clark
Am 04.06.2013, 04:57 Uhr, schrieb Rob Green robsgr...@gmail.com: Hello, I'm having some trouble getting my SQL query to work in SQLAlchemy. In this example, I want to find out the number of meeting rooms and bathrooms available to a user. The user is part of a userGroup, which is assigned to

[sqlalchemy] Retrieve Dates as UTC

2013-06-05 Thread Owen M
Was hunting around for how to do this, and couldn't find any examples, but eventually figured it out. Goal is to have all dates coming out of Postgres to be in UTC, regardless of the DBA's timezone configuration. Key piece of code is as follows: import sqlalchemy def

Re: [sqlalchemy] Retrieve Dates as UTC

2013-06-05 Thread Michael Bayer
we do this (for PG and SQL Server): class utcnow(expression.FunctionElement): key = 'utcnow' type = DateTime() @compiles(utcnow, 'postgresql') def _pg_utcnow(element, compiler, **kw): return TIMEZONE('utc', CURRENT_TIMESTAMP) @compiles(utcnow, 'mssql') def _ms_utcnow(element,

[sqlalchemy] Connect to SQL Server (with pyodbc) getting error: sqlalchemy.exc.DBAPIError: (Error) ('IM002', '[IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver

2013-06-05 Thread Victor Reichert
Hello World! This is my first foray into python and SQL Alchemy, and I'm spinning my wheels. I'm running the code below and am able to connect to my DB and query data without error. import pyodbc cnxn = pyodbc.connect('DSN=py_test; Trusted_Connection=Yes') However, when I try import