[sqlalchemy] [Q][0.7.9] problem with with_entities(), over() and label()

2013-06-06 Thread Ladislav Lenart
Hello. I am trying to adapt WindowedRangeQuery recipe http://www.sqlalchemy.org/trac/wiki/UsageRecipes/WindowedRangeQuery I have just stumbled upon the following issue: def _q_windows(self, window_size): q = self._query.with_entities( self._column,

Re: [sqlalchemy] Retrieve Dates as UTC

2013-06-06 Thread Owen M
As far as I can tell that is just for setting the time. By the linked documentation, using server_default. Postgres stores all datetimes as UTC and then does the conversion on query, depending on the timezone set in the connection. This defaults to the computer's timezone. In my submission it

Re: [sqlalchemy] [Q][0.7.9] problem with with_entities(), over() and label()

2013-06-06 Thread Ladislav Lenart
Hello. I have already solved the issue by using subquery: SELECT t.id AS t_id, t.rownum AS t_rownum FROM ( SELECT FROM foo.id AS id, row_number() OVER (ORDER BY foo.id) AS rownum ) AS t WHERE rownum % 50 = 1 I have just tried your suggestion about using HAVING

Re: [sqlalchemy] Query and compiled_cache

2013-06-06 Thread Claudio Freire
On Tue, Jun 4, 2013 at 5:26 PM, Claudio Freire klaussfre...@gmail.com wrote: On Sun, Jun 2, 2013 at 9:41 PM, Claudio Freire klaussfre...@gmail.com wrote: 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,

Re: [sqlalchemy] Query and compiled_cache

2013-06-06 Thread Michael Bayer
On Jun 6, 2013, at 1:03 PM, Claudio Freire klaussfre...@gmail.com wrote: On Tue, Jun 4, 2013 at 5:26 PM, Claudio Freire klaussfre...@gmail.com wrote: On Sun, Jun 2, 2013 at 9:41 PM, Claudio Freire klaussfre...@gmail.com wrote: So the whole thing is rolled up into the named thing I referred

Re: [sqlalchemy] [Q][0.7.9] problem with with_entities(), over() and label()

2013-06-06 Thread Michael Bayer
On Jun 6, 2013, at 12:56 PM, Ladislav Lenart lenart...@volny.cz wrote: Hello. I have already solved the issue by using subquery: SELECT t.id AS t_id, t.rownum AS t_rownum FROM ( SELECT FROM foo.id AS id, row_number() OVER (ORDER BY foo.id) AS rownum ) AS

Re: [sqlalchemy] [Q][0.7.9] problem with with_entities(), over() and label()

2013-06-06 Thread Charlie Clark
Am 06.06.2013, 18:56 Uhr, schrieb Ladislav Lenart lenart...@volny.cz: Hello. I have already solved the issue by using subquery: SELECT t.id AS t_id, t.rownum AS t_rownum FROM ( SELECT FROM foo.id AS id, row_number() OVER (ORDER BY foo.id) AS rownum ) AS t WHERE

Re: [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 dri

2013-06-06 Thread Michael Bayer
I will show you a short program that you can use to experiment with the Pyodbc connector - the purpose of this program is to illustrate what SQLAlchemy will send to pyodbc.connect(): from sqlalchemy.connectors import pyodbc from sqlalchemy.engine.url import make_url conn =

[sqlalchemy] Feature suggestion: fake ForeignKeyConstraints to simplify joins

2013-06-06 Thread Andy
I've written a handful of primaryjoin and secondaryjoin attributes on Relationships. This mechanism is flexible, but it's error-prone, and I think that, at least for all the cases I've personally encountered, there could be a better way. As an example, I have: thing = Table('thing',

Re: [sqlalchemy] Feature suggestion: fake ForeignKeyConstraints to simplify joins

2013-06-06 Thread Michael Bayer
On Jun 6, 2013, at 2:21 PM, Andy aml...@gmail.com wrote: I've written a handful of primaryjoin and secondaryjoin attributes on Relationships. This mechanism is flexible, but it's error-prone, and I think that, at least for all the cases I've personally encountered, there could be a

Re: [sqlalchemy] Feature suggestion: fake ForeignKeyConstraints to simplify joins

2013-06-06 Thread Michael Bayer
On Jun 6, 2013, at 3:21 PM, Michael Bayer mike...@zzzcomputing.com wrote: Not only that, but we are now placing ORM-specific configuration into our Table metadata. What's wrong with doing it in relationship()?Clearly, the way primaryjoin works, in that it's an expression, is

Re: [sqlalchemy] Feature suggestion: fake ForeignKeyConstraints to simplify joins

2013-06-06 Thread Charlie Clark
Am 06.06.2013, 20:21 Uhr, schrieb Andy aml...@gmail.com: IOW I have things and groups. The rel table is a many-to-many relation between things and groups. A thing also may have a favorite group; if so, there has to be a rel between that thing and its favorite group. Are favourites

Re: [sqlalchemy] Feature suggestion: fake ForeignKeyConstraints to simplify joins

2013-06-06 Thread Michael Bayer
On Jun 6, 2013, at 5:18 PM, Charlie Clark charlie.cl...@clark-consulting.eu wrote: Am 06.06.2013, 20:21 Uhr, schrieb Andy aml...@gmail.com: IOW I have things and groups. The rel table is a many-to-many relation between things and groups. A thing also may have a favorite group; if so,

Re: [sqlalchemy] Feature suggestion: fake ForeignKeyConstraints to simplify joins

2013-06-06 Thread Charlie Clark
Am 06.06.2013, 23:36 Uhr, schrieb Michael Bayer mike...@zzzcomputing.com: On Jun 6, 2013, at 5:18 PM, Charlie Clark charlie.cl...@clark-consulting.eu wrote: Am 06.06.2013, 20:21 Uhr, schrieb Andy aml...@gmail.com: IOW I have things and groups. The rel table is a many-to-many relation

Re: [sqlalchemy] Feature suggestion: fake ForeignKeyConstraints to simplify joins

2013-06-06 Thread Michael Bayer
On Jun 6, 2013, at 5:40 PM, Charlie Clark charlie.cl...@clark-consulting.eu wrote: Am 06.06.2013, 23:36 Uhr, schrieb Michael Bayer mike...@zzzcomputing.com: On Jun 6, 2013, at 5:18 PM, Charlie Clark charlie.cl...@clark-consulting.eu wrote: Am 06.06.2013, 20:21 Uhr, schrieb Andy

Re: [sqlalchemy] Feature suggestion: fake ForeignKeyConstraints to simplify joins

2013-06-06 Thread Andy
On Thursday, June 6, 2013 2:40:57 PM UTC-7, Charlie Clark wrote: Am 06.06.2013, 23:36 Uhr, schrieb Michael Bayer mik...@zzzcomputing.comjavascript:: On Jun 6, 2013, at 5:18 PM, Charlie Clark charli...@clark-consulting.eu javascript: wrote: Am 06.06.2013, 20:21 Uhr, schrieb

[sqlalchemy] [BUG][PATCH] Function names not quoted when necessary

2013-06-06 Thread Ryan Kelly
Function names in SQL can contain pretty much anything, e.g.: =# create function A Bug?(integer) returns integer as $$ select $1; $$ language sql; CREATE FUNCTION But when attempting to use the function from SQLAlchemy: from sqlalchemy.sql.expression import func bug = getattr(func, A Bug?)(1)