Re: [sqlalchemy] InvalidRequestError: Can't reconnect until invalid transaction is rolled back error during SELECT query

2012-12-05 Thread Piotr Deszyński
A simple test case can be found here https://gist.github.com/4214092 Expected result: Query returns a list of results from database Current behaviour: Query throws an exception: https://gist.github.com/4214131 W dniu środa, 5 grudnia 2012 07:54:48 UTC+1 użytkownik Piotr Deszyński napisał: If

Re: [sqlalchemy] InvalidRequestError: Can't reconnect until invalid transaction is rolled back error during SELECT query

2012-12-05 Thread Piotr Deszyński
Ok, got it working. Sorry for the problem. W dniu wtorek, 4 grudnia 2012 16:31:16 UTC+1 użytkownik Michael Bayer napisał: test cases and stack traces would be a start On Dec 4, 2012, at 9:29 AM, Piotr Deszyński wrote: Hello, Is there a way to use ZopeTransactionExtension using

Re: [sqlalchemy] Do we have a sqlalchemy code or migration script to enforce foreign key constraint for sqlite3?

2012-12-05 Thread junepeach
I am Python 2.7.3, and SQLite version 3.7.9. I added the code you guys mentioned above to the env.py script: from __future__ import with_statement from alembic import context from sqlalchemy import engine_from_config, pool from logging.config import fileConfig # this is the Alembic Config

Re: [sqlalchemy] Do we have a sqlalchemy code or migration script to enforce foreign key constraint for sqlite3?

2012-12-05 Thread junepeach
I think one of my problems is after defining: def set_sqlite_pragma(dbapi_connection, connection_record) in env.py, Where I should call it and what are the values of 2 arguments: dbapi_connection, connection_record? -- You received this message because you are subscribed to the Google

Re: [sqlalchemy] Do we have a sqlalchemy code or migration script to enforce foreign key constraint for sqlite3?

2012-12-05 Thread Audrius Kažukauskas
On Wed, 2012-12-05 at 06:32:46 -0800, junepeach wrote: When I logged in sqlite by 'sqlite3 mydb', and checked 'PRAGMA foreign_keys', it is still 0. There is no change yet. What is wrong? It doesn't work like that. From http://www.sqlite.org/foreignkeys.html: Foreign key constraints are

Re: [sqlalchemy] Do we have a sqlalchemy code or migration script to enforce foreign key constraint for sqlite3?

2012-12-05 Thread Audrius Kažukauskas
On Wed, 2012-12-05 at 06:43:33 -0800, junepeach wrote: I think one of my problems is after defining: def set_sqlite_pragma(dbapi_connection, connection_record) in env.py, Where I should call it and what are the values of 2 arguments: dbapi_connection, connection_record? You don't have to

Re: [sqlalchemy] Do we have a sqlalchemy code or migration script to enforce foreign key constraint for sqlite3?

2012-12-05 Thread junepeach
Thank you Audrius.Maybe when I ran 'alembic upgrade head', 'PRAGMA foreign_keys' value of the current sqlite DB connection was already changed to 1 which I need to test in a python code. However when I manually logged in by typing 'sqlite3 mydb', this is another connection, so the 'PRAGMA

Re: [sqlalchemy] Do we have a sqlalchemy code or migration script to enforce foreign key constraint for sqlite3?

2012-12-05 Thread junepeach
I was wrong in above post. -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To view this discussion on the web visit https://groups.google.com/d/msg/sqlalchemy/-/sgyxJHCVUm0J. To post to this group, send email to sqlalchemy@googlegroups.com. To

Re: [sqlalchemy] Do we have a sqlalchemy code or migration script to enforce foreign key constraint for sqlite3?

2012-12-05 Thread Audrius Kažukauskas
On Wed, 2012-12-05 at 07:04:57 -0800, junepeach wrote: Thank you Audrius.Maybe when I ran 'alembic upgrade head', 'PRAGMA foreign_keys' value of the current sqlite DB connection was already changed to 1 which I need to test in a python code. However when I manually logged in by typing 'sqlite3

Re: [sqlalchemy] Bug Report: A regression in the MSSQL Dialect in 0.8.x

2012-12-05 Thread Michael Bayer
On Dec 4, 2012, at 6:27 PM, Derek Harland wrote: Yes In that case, how does SQL server make the distinction? If things have an embedded . then SQL server would ideally make the distinction based on you quoting the database/schema names. This could be done in the Transact-SQL

Re: [sqlalchemy] Do we have a sqlalchemy code or migration script to enforce foreign key constraint for sqlite3?

2012-12-05 Thread junepeach
I just did a testing, basically copied and ran the code of below link: http://docs.sqlalchemy.org/en/rel_0_8/core/tutorial.html in the middle of process, I copied and ran below code: from sqlalchemy.engine import Enginefrom sqlalchemy import event @event.listens_for(Engine, connect)def

Re: [sqlalchemy] Do we have a sqlalchemy code or migration script to enforce foreign key constraint for sqlite3?

2012-12-05 Thread Audrius Kažukauskas
On Wed, 2012-12-05 at 09:07:20 -0800, junepeach wrote: I just did a testing, basically copied and ran the code of below link: http://docs.sqlalchemy.org/en/rel_0_8/core/tutorial.html in the middle of process, I copied and ran below code: from sqlalchemy.engine import Engine from sqlalchemy

Re: [sqlalchemy] Do we have a sqlalchemy code or migration script to enforce foreign key constraint for sqlite3?

2012-12-05 Thread junepeach
Audrius Kažukauskas Hi Audrius, Your code works like a charm. Thank you so much for your help! I really appreciate! On Wednesday, December 5, 2012 12:53:25 PM UTC-5, Audrius Kažukauskas wrote: On Wed, 2012-12-05 at 09:07:20 -0800, junepeach wrote: I just did a testing, basically copied and

[sqlalchemy] Why not seeing ondelete='xxx', and onupdate='xxx' in alembic migration script?

2012-12-05 Thread junepeach
I defined several tables in my module file: mymodule.py. For example I have table T1 and T2 defined: class T1(Base): __tablename__ = 't1' id = Column(Integer, primary_key = True) name = Column(String(15)) class T2(Base): __tablename__ = 't2' id = Column(Integer, primary_key =

Re: [sqlalchemy] Why not seeing ondelete='xxx', and onupdate='xxx' in alembic migration script?

2012-12-05 Thread Michael Bayer
On Dec 5, 2012, at 2:56 PM, junepeach wrote: I defined several tables in my module file: mymodule.py. For example I have table T1 and T2 defined: class T1(Base): __tablename__ = 't1' id = Column(Integer, primary_key = True) name = Column(String(15)) class T2(Base):

[sqlalchemy] tsvector

2012-12-05 Thread Gery .
I was searching in google about tsvector (postgresql) implemented in sqlalchemy or geoalchemy but seems to me that it's not implemented yet. After searching for it in [1], it didn't match anything. Sanjay, however, gives a way to do this [2] but seems confusing to me, is it possible to use

[sqlalchemy] Best practice for faves/likes counting?

2012-12-05 Thread Hong Minhee
Hi, I am making a typical web application using SQLAlchemy, and it contains “users”, “works” and “likes”: - users ( id, login, … ) - works ( id, title, … ) - likes ( user_id, work_id ) I want to print how many users liked each work, so the most simple (but naive) is querying count

Re: [sqlalchemy] tsvector

2012-12-05 Thread Michael Bayer
sanjay's approach there is hardcoded SQL which isn't necessary with SQLAlchemy (though always supported as a quick approach to something). tsvector here as a type can be implemented with UserDefinedType: http://docs.sqlalchemy.org/en/rel_0_8/core/types.html#sqlalchemy.types.UserDefinedType and

Re: [sqlalchemy] Bug Report: A regression in the MSSQL Dialect in 0.8.x

2012-12-05 Thread Derek Harland
On 6/12/2012, at 5:26 AM, Michael Bayer wrote: On Dec 4, 2012, at 6:27 PM, Derek Harland wrote: Yes In that case, how does SQL server make the distinction? If things have an embedded . then SQL server would ideally make the distinction based on you quoting the database/schema

Re: [sqlalchemy] Creating a feed related to different object type

2012-12-05 Thread Eric Ongerth
Hi Brice, I think something strange happened in the discussion group web page because it did not show me the existence of the message in which you linked to your solution. If I had seen that I would have known that you already found the way. Cheers, Eric On Sunday, December 2, 2012 8:00:05

Re: [sqlalchemy] Why not seeing ondelete='xxx', and onupdate='xxx' in alembic migration script?

2012-12-05 Thread Eric Ongerth
Thank you very much for that resolution! I use these a lot. On Wednesday, December 5, 2012 12:37:54 PM UTC-8, Michael Bayer wrote: On Dec 5, 2012, at 2:56 PM, junepeach wrote: I defined several tables in my module file: mymodule.py. For example I have table T1 and T2 defined: class

[sqlalchemy] Re: Best practice for faves/likes counting?

2012-12-05 Thread Eric Ongerth
But work.like_query.count() will be efficient if you have the right indexes in the database, no? I think if you want to denormalize that count all the way and also stay very efficient, maybe it would be good to do it right on the db server with a trigger and a stored procedure and avoid extra

[sqlalchemy] Re: Best practice for faves/likes counting?

2012-12-05 Thread Hong Minhee
But for work in works: work.like_query.count() causes inefficient 1+N queries even if we have the right indices for it. Of course I could query like session.query(Work, count()).join(Work.like_set).group_by(Work) but it’s somewhat complicated to read and write for me (is it only me?). I want