[sqlalchemy] how to use substring in the where clause?

2012-03-08 Thread Timuçin Kızılay
I have a query contains SUBSTRING in where clause: Select top 100 * from _Doc where SUBSTRING(_Doc.FileNameStr, 22, 1) = '2' --- This query runs on mssql but I need to use that query from sa. I could not find anything like this in SA documentatin. Here is what I tried so far: q_doc =

[sqlalchemy] complex update query

2012-03-08 Thread yannack
Hello list, I have the following models (excerpt) which represent a scoring system (the score is the extra value, it is linked to a scorecard): class Scoring(Base): __tablename__ = 'scraper_scoring' scoring_id = Column('id',Integer, primary_key=True) extra = Column(Integer,

Re: [sqlalchemy] how to use substring in the where clause?

2012-03-08 Thread Robert Forkel
sqlalchemy.sql.expression.func may work for this: from sqlalchemy.sql.expression import func ... q_doc.filter(func.substring(model.Doc.FileNameStr, 22, 1)==search_str) ... 2012/3/8 Timuçin Kızılay t...@savaskarsitlari.org: I have a query contains SUBSTRING in where clause: Select top 100 *

Re: [sqlalchemy] how to use substring in the where clause?

2012-03-08 Thread Timuçin Kızılay
Thank you. it works now. But what is the difference between from sqlalchemy.sql.expression import func and from sqlalchemy import func the second import is what I found out while experimenting with the query and after I saw your reply, I tried your code and both works the same. On

Re: [sqlalchemy] how to use substring in the where clause?

2012-03-08 Thread Robert Forkel
from sqlalchemy.sql.expression import func from sqlalchemy import func as other_func func == other_func True 2012/3/8 Timuçin Kızılay t...@savaskarsitlari.org: Thank you. it works now. But what is the difference between from sqlalchemy.sql.expression import func and from sqlalchemy

[sqlalchemy] Security issues?

2012-03-08 Thread Vlad K.
Hi all, I was wondering if there is some kind of security announcements mailing list or anything where we could be informed of security issues directly from the horse's mouth? :) I did join the mailing list after 0.7.0 was released so I can't tell if this particular issue was mentioned, a

[sqlalchemy] simple locking issue

2012-03-08 Thread Eric Lemoine
Hi My code basically does: --- engine = create_engine() table = Table('table', MetaData(), Column('id', Integer, primary_key=True)) table.create(bind=engine) Session = scoped_session(sessionmaker(bind=engine)) Session.execute(text('SELECT id from table')) --- The last statement blocks

[sqlalchemy] Bug? Cannot call super().__init__ in class which extends declarative_base

2012-03-08 Thread Adam Parkin
When augmenting the basehttp://docs.sqlalchemy.org/en/latest/orm/extensions/declarative.html?highlight=declarative_base#augmenting-the-baseyou create a class, and then tell declarative_base to inherit from the class you've created. Ex: class MyBase(object): def __init__(self): #

[sqlalchemy] CompileError with or_() or union() on nested has() queries that involve composite joins

2012-03-08 Thread Christopher Abiad
I'm having issues with certain types of queries in my application that involve has(), or_(), and composite joins. I've created the most simple example I could that still produces the error and included it below. The classes involved in this are fairly contrived, but mirror my application's real

Re: [sqlalchemy] Bug? Cannot call super().__init__ in class which extends declarative_base

2012-03-08 Thread Michael Bayer
On Mar 8, 2012, at 1:15 PM, Adam Parkin wrote: When augmenting the base you create a class, and then tell declarative_base to inherit from the class you've created. Ex: class MyBase(object): def __init__(self): # code here Base = declarative_base(cls=MyBase) class

Re: [sqlalchemy] Immediate Need Java Developer -- NY// Full Time

2012-03-08 Thread Chris Withers
Mike, can you kickban this retard please. On 28/02/2012 06:30, Naveen kumar wrote: Dear IT Professional, Hope you are doing great, This is Naveen Kumar from Panzer Solutions, LLC Chris -- Simplistix - Content Management, Batch Processing Python Consulting -

[sqlalchemy] Possible Cacheing issue with SQLAlchemy

2012-03-08 Thread ypg
I am running SQLAlchemy under a multithreaded python server (paster), as part of a web application which is written using the Python Pyramid framework. When I modify an existing database entry through SQL alchemy, subsequent page refreshes seem to randomly pick between the original instance of

Re: [sqlalchemy] Possible Cacheing issue with SQLAlchemy

2012-03-08 Thread Chris Withers
On 08/03/2012 16:23, ypg wrote: I am using a single scoped_session instance to create the sessions, Can we see some code, small preferably? which is global to all the threads running in the web application. That sounds like a really bad idea. I can solve this issue by creating a new

Re: [sqlalchemy] Possible Cacheing issue with SQLAlchemy

2012-03-08 Thread Michael Bayer
On Mar 8, 2012, at 4:23 PM, ypg wrote: I am running SQLAlchemy under a multithreaded python server (paster), as part of a web application which is written using the Python Pyramid framework. When I modify an existing database entry through SQL alchemy, subsequent page refreshes seem to

Re: [sqlalchemy] Possible Cacheing issue with SQLAlchemy

2012-03-08 Thread Michael Bayer
On Mar 8, 2012, at 4:34 PM, Chris Withers wrote: avoid doing that. I'm using a NullPool connection to the database engine, by the way, just in case that would change anything. Why would you do that? I advise using NullPool with SQLite in the docs, if you use SQLA 0.7 the SQLite dialect

[sqlalchemy] Handle DetachedInstanceError and object sharing between Thread

2012-03-08 Thread zz elle
Hi everyone, I join an application dev team in order to solve 2 main problems with SA on an application that use SA the wrong way. Indeed the dev team did not understood that sessions are ad-hoc (as said by Mike if i remember well). So they get DetachedInstanceError sometimes on lazy loads.

Re: [sqlalchemy] Handle DetachedInstanceError and object sharing between Thread

2012-03-08 Thread Michael Bayer
On Mar 8, 2012, at 4:45 PM, zz elle wrote: Hi everyone, I join an application dev team in order to solve 2 main problems with SA on an application that use SA the wrong way. Indeed the dev team did not understood that sessions are ad-hoc (as said by Mike if i remember well). So

[sqlalchemy] Re: Possible Cacheing issue with SQLAlchemy

2012-03-08 Thread ypg
Ah, so it seems I was most confused about the intended usage of the scoped session - I was assuming that because it was designed to be multithreaded, that would imply that the same instance would be used for more than one request ... because an individual request is typically handled by a single

[sqlalchemy] Turning a Query instance into SQL (with parameters), need help w/ LIMIT/OFFSET in 0.7.x

2012-03-08 Thread Randy Syring
I found a recipe on stackoverflow for turning a query instance into a string, including parameters. I only do this for testing purposes and the implementation is here: https://bitbucket.org/rsyring/sqlalchemybwc/src/292597b37736/sqlalchemybwc/lib/testing.py However, I just upgraded to 0.7.5