[sqlalchemy] Appending a where clause to a query

2011-04-27 Thread Luka Novsak
The docs on Select's where() method say: return a new select() construct with the given expression added to its WHERE clause, joined to the existing clause via AND, if any. But this doesn't seem to happen. This is my code: def posts_per_dow(self, start_date=None, end_date=None):

[sqlalchemy] sqlite transaction isolation, select for update, race condition

2011-04-27 Thread Clay Gerrard
Yesterday I was working with some code that needed a select ... for update concept to avoid a race condition. Adding .with_lockmode('update') works a treat on InnoDB and Postgres, but for sqlite I end up having to sneak in a if session.bind.name == 'sqlite'; session.execute('begin immediate

RE: [sqlalchemy] Appending a where clause to a query

2011-04-27 Thread King Simon-NFHD78
-Original Message- From: sqlalchemy@googlegroups.com [mailto:sqlalchemy@googlegroups.com] On Behalf Of Luka Novsak Sent: 27 April 2011 05:32 To: sqlalchemy Subject: [sqlalchemy] Appending a where clause to a query The docs on Select's where() method say: return a new select()

[sqlalchemy] Re: API that allows me to do additional database operations just before insert execution for SQL Expression

2011-04-27 Thread bool
I want to some updates before doing any insert. So I needed the above. Now the issue I am facing is that I need all these updates and the current insert to be in a transaction. That is either all should be successful or none. How is that possible with a connection proxy (something like below)?

Re: [sqlalchemy] sqlite transaction isolation, select for update, race condition

2011-04-27 Thread Michael Bayer
SQLite doesn't have support for SELECT..FOR UPDATE, and with_lockmode() ultimately has no impact when using SQLite as nothing is rendered. SQLite's concurrency model is based on a lock of the entire database file - hardly a row lock - I wouldn't think such a strategy applies on that backend ?

Re: [sqlalchemy] sqlite transaction isolation, select for update, race condition

2011-04-27 Thread Daniel Holth
Is this pysqlite issue about SELECT not starting a transaction related? http://code.google.com/p/pysqlite/issues/detail?id=21 -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com. To

Re: [sqlalchemy] Facing problem with aliasing while using union_all

2011-04-27 Thread monster jacker
The Query should return to you tuples that have names like row_num and test_msg, which are linked to the anon names that it generates: for row in myquery: print row.row_num, row.test_msg that is, the anon_x names do not matter. they are an artifact of how the Query does its work and the

Re: [sqlalchemy] Facing problem with aliasing while using union_all

2011-04-27 Thread Michael Bayer
On Apr 27, 2011, at 10:58 AM, monster jacker wrote: The Query should return to you tuples that have names like row_num and test_msg, which are linked to the anon names that it generates: for row in myquery: print row.row_num, row.test_msg that is, the anon_x names do

Re: [sqlalchemy] Facing problem with aliasing while using union_all

2011-04-27 Thread Michael Bayer
On Apr 27, 2011, at 10:58 AM, monster jacker wrote: The Query should return to you tuples that have names like row_num and test_msg, which are linked to the anon names that it generates: for row in myquery: print row.row_num, row.test_msg that is, the anon_x names do

[sqlalchemy] Re: sqlite transaction isolation, select for update, race condition

2011-04-27 Thread Clay Gerrard
On Apr 27, 9:19 am, Michael Bayer mike...@zzzcomputing.com wrote: SQLite doesn't have support for SELECT..FOR UPDATE, and with_lockmode() ultimately has no impact when using SQLite as nothing is rendered.   IDK why sqlite doesn't support a way to elevate the lock on a select in the middle of

Re: [sqlalchemy] Re: sqlite transaction isolation, select for update, race condition

2011-04-27 Thread Michael Bayer
On Apr 27, 2011, at 11:18 AM, Clay Gerrard wrote: On Apr 27, 9:19 am, Michael Bayer mike...@zzzcomputing.com wrote: SQLite doesn't have support for SELECT..FOR UPDATE, and with_lockmode() ultimately has no impact when using SQLite as nothing is rendered. IDK why sqlite doesn't

[sqlalchemy] Re: sqlite transaction isolation, select for update, race condition

2011-04-27 Thread Clay Gerrard
On Apr 27, 9:37 am, Daniel Holth dho...@gmail.com wrote: Is this pysqlite issue about SELECT not starting a transaction related?http://code.google.com/p/pysqlite/issues/detail?id=21 Hrmmm... well... that's interesting... it might be related, but maybe not? I'm not setting the isolation

Re: [sqlalchemy] Multi-table (polymorphic?) row-specific relations

2011-04-27 Thread Michael Bayer
On Apr 25, 2011, at 9:10 PM, Andrey Petrov wrote: One more thought: Is there a sane way to hide a schema object within another schema object? Specifically, I want to make a factory method (or maybe a class decorator) which generates these Tag schemas onto specific tables. Something

Re: [sqlalchemy] Multi-table (polymorphic?) row-specific relations

2011-04-27 Thread Michael Bayer
this works (been working on getting this kind of thing into recipes/docs/books) from sqlalchemy import Column, Integer, ForeignKey, String from sqlalchemy.ext.declarative import declarative_base, declared_attr from sqlalchemy.orm import relationship Base = declarative_base() class

[sqlalchemy] Re: sqlite transaction isolation, select for update, race condition

2011-04-27 Thread Clay Gerrard
On Apr 27, 10:41 am, Michael Bayer mike...@zzzcomputing.com wrote: then yes, for your case this is exactly the pysqlite bug Daniel mentions:   http://code.google.com/p/pysqlite/issues/detail?id=21.  Pysqlite doesn't open the transaction until DML is encountered specifically to reduce file

Re: [sqlalchemy] Multi-table (polymorphic?) row-specific relations

2011-04-27 Thread Andrey Petrov
Ah I was really close. This worked: class TagMixin(object): @declared_attr def tags(cls): class Tag(BaseModel): __tablename__ = tag_%s % cls.__tablename__ id = Column(types.Integer, primary_key=True) time_created = Column(types.DateTime,

[sqlalchemy] datetime is causing error when accesing MSSQL via sqlalchemy - pyodbc/TDS

2011-04-27 Thread Thang Nguyen
Hi, I am getting an error accessing MSSQL database using sqlalchemy/pyodbc/TDS driver. After narrowing the case, looks like it has something to do with datetime datatype. If I deldete the created_at column (datetime) then the same code will work. Any suggestion for further debugging? Thanks in

Re: [sqlalchemy] datetime is causing error when accesing MSSQL via sqlalchemy - pyodbc/TDS

2011-04-27 Thread Michael Bayer
that error is generated by TDS/pyodbc and is not related to SQLAlchemy. Here's your test case with pyodbc alone, the pyodbc or FreeTDS lists might have further info: import pyodbc conn = pyodbc.connect(DRIVER={FreeTDS};SERVER=myserver;DATABASE=mydatabase;PORT=1435;UID=MYUSER;PWD=MYPASS1)

[sqlalchemy] Oracle reserved words

2011-04-27 Thread Sirko Schroeder
I have a problem with oracle column names that are oracle reserved words (http://download.oracle.com/docs/cd/B19306_01/em.102/b40103/ app_oracle_reserved_words.htm). I read through the archive and found: