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

2012-03-09 Thread Michael Bayer
i haven't followed this closely, worth updating the recipe on the SQLA wiki ?



On Mar 9, 2012, at 2:06 PM, Randy Syring wrote:

> I checked out that function and it turns out that I actually do have problems 
> with:
> 
> q = db.sess.query(Blog).filter(Blog.title == u'foo').limit(10).offset(5)
> 
> results in:
> 
> SELECT blogs.id, blogs.createdts, blogs.updatedts, blogs.title, blogs.ident 
> FROM blogs 
> WHERE blogs.title = ?
>  LIMIT ? OFFSET ?
> 
> However, I was mistaken in my original post.  The problem was not with the 
> helper function but with the way I was doing my testing.  The full 
> implementation of the helper function is here:
> 
> http://stackoverflow.com/a/5698357/182111
> 
> -
> Randy Syring
> Development & Executive Director
> Level 12 Technologies (formerly Intelicom)
> Direct: 502-276-0459
> Office: 502-212-9913
> 
> Intelicom is now Level 12 Technologies, learn more about our name change.
> Please update your address book with my new email address.
> 
> Principled People, Technology that Works
> 
> On 03/09/2012 03:25 AM, Alex K wrote:
>> 
>> We use this recipe and in 0.7.5 it works ok with limit and offset.
>> 
>> http://www.sqlalchemy.org/trac/wiki/UsageRecipes/old/DebugInlineParams
>> 
>> 
>> On Fri, Mar 9, 2012 at 10:32 AM, Randy Syring  wrote:
>> 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 and it would appear this recipe does not 
>> handle LIMIT/OFFSET becoming parameterized.  I get the following when using 
>> the function:
>> 
>> "...persons.last_name AS persons_last_name FROM persons LIMIT :param_1 
>> OFFSET :param_2"
>> 
>> I'm in over my head on SA internals on this one and would appreciate 
>> suggestions.
>> 
>> Thanks in advance.
>> -- 
>> 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/-/ryYu6nVG-RQJ.
>> To post to this group, send email to sqlalchemy@googlegroups.com.
>> To unsubscribe from this group, send email to 
>> sqlalchemy+unsubscr...@googlegroups.com.
>> For more options, visit this group at 
>> http://groups.google.com/group/sqlalchemy?hl=en.
>> 
>> -- 
>> 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 unsubscribe from this group, send email to 
>> sqlalchemy+unsubscr...@googlegroups.com.
>> For more options, visit this group at 
>> http://groups.google.com/group/sqlalchemy?hl=en.
> 
> 
> -- 
> 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 unsubscribe from this group, send email to 
> sqlalchemy+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/sqlalchemy?hl=en.

-- 
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 unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.



Re: [sqlalchemy] Attribute modified but object not in session.dirty

2012-03-09 Thread Michael Bayer
this is in-place mutation so you need to send SQLAlchemy a signal that 
something has changed using the Mutable interface, which involves subclassing 
array.array.  See the docs at 
http://docs.sqlalchemy.org/en/latest/orm/extensions/mutable.html for how this 
works.


On Mar 9, 2012, at 5:11 AM, Andrea wrote:

> Hi all,
> at http://pastebin.com/jYsZwj10 an extract of my code.
> I create a custom type HexString that extends TypeDecorator. When I
> modify an
> object of this type on a persisted instance, changes don't affect
> session.
> I need some help, tnx.
> 
> Andrea
> 
> -- 
> 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 unsubscribe from this group, send email to 
> sqlalchemy+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/sqlalchemy?hl=en.
> 

-- 
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 unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.



Re: [sqlalchemy] Using expression language to create temporary tables

2012-03-09 Thread Michael Bayer

On Mar 9, 2012, at 11:46 AM, Sharon wrote:

> Greetings:
> 
> Just started looking at SqlAlchemy as we may want to use its sql expression 
> language to abstract our (sometimes) database specific sql. 
> 
> To create a temporary table in postgresql we would typically do something 
> like this:
> 
> SELECT m._marker_key, m.symbol
> INTO TEMPORARY TABLE tmp_markers
> FROM mrk_marker m
> WHERE m._organism_key == 1
> AND m._marker_status_key IN (1,3)
>   
> To do this using sqlalchemy I have done the following, see below. I don't see 
> a way to SELECT INTO using sqlalchemy. Is there a simpler way? Thanks for 
> your help!!


I'd agree you should use that format, though SQLAlchemy doesn't have direct 
support for this idiom at the moment. Here's a recipe that provides it:


from sqlalchemy.sql import Select
from sqlalchemy.ext.compiler import compiles

class SelectInto(Select):
def __init__(self, columns, into, *arg, **kw):
super(SelectInto, self).__init__(columns, *arg, **kw)
self.into = into

@compiles(SelectInto)
def s_into(element, compiler, **kw):
text = compiler.visit_select(element)
text = text.replace('FROM', 
'INTO TEMPORARY TABLE %s FROM' % 
element.into)
return text


if __name__ == '__main__':
from sqlalchemy.sql import table, column

marker = table('marker', 
column('x1'),
column('x2'),
column('x3')
)

print SelectInto([marker.c.x1, marker.c.x2], "tmp_markers").\
where(marker.c.x3==5).\
where(marker.c.x1.in_([1, 5]))




> 
> # create the temporary table
> tmp_markers = Table('tmp_markers', metadata,
> Column('_marker_key', Integer, index=True),
> Column('symbol', String(50) ),
> prefixes=['TEMPORARY']
> )
> tmp_markers.create()
> 
> # create the connection after create the temporary table
> connection = engine.connect()
> 
> # Query with which to load 'tmp_markers'
> query = select([m.c._marker_key, m.c.symbol],
>and_ (
> m.c._organism_key == 1,
> m.c._marker_status_key.in_([1,3]),
> )
> )
> 
> # execute the query
> results = connection.execute(query)
> 
> # create the insert expression
> ins_tmp = tmp_markers.insert()
> 
> # create list of results to insert into 'tmp_markers'
> ins_tmp_list = []
> for r in results:
> ins_tmp_list.append({
> '_marker_key':  r[m.c._marker_key],
> 'symbol':   r[m.c.symbol],
> })
> results.close()
> 
> # insert into 'tmp_markers'
> connection.execute(ins_tmp, ins_tmp_list)
> 
> 
> 
> 
> -- 
> 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/-/B8Umq9y08EoJ.
> To post to this group, send email to sqlalchemy@googlegroups.com.
> To unsubscribe from this group, send email to 
> sqlalchemy+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/sqlalchemy?hl=en.

-- 
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 unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.



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

2012-03-09 Thread zz elle

A custom query_cls POC to define in the sessionmaker (i simplify thing by 
only supporting queries which only request one entity):
WrapperQuery : 
==> the wrapper checks SA object session before getting an SA object 
attribute (and if needed we merge it with a new session)
==> merging seems to be costly so i think it must be used with 
scoped_session
==> awfully unefficient if the object is shared between multiples threads 
which get attributes on the same object at the same time
MemoizeWrapperQuery: 
==> the wrapper also memoizes every SA object attributes. 
==> it avoid to check session and merge SA object even when getting SA 
object already loaded attribute
==> we could improve memoize by memoizing SA object already loaded 
attributes on wrapper __init__

Both are not only usable if used for read actions

merging seems to be costly so i think i should

class Wrapper(object):
> def __init__(self, wrapped):
> self._wrapped = wrapped
> self._lock = threading.Lock()
>
> def __getattr__(self, name):
> if name == '_sa_instance_state':
> return self._wrapped._sa_instance_state
> old_session = object_session(self._wrapped)
> new_session = api.get_session()
> with self._lock:
> if old_session is not new_session:
> self._wrapped = new_session.merge(self._wrapped)
> return getattr(self._wrapped, name)
>
> class CachedWrapper(object):
> def __init__(self, wrapped):
> self._wrapped = wrapped
> self._lock = threading.Lock()
>
> def __getattr__(self, name):
> if name == '_sa_instance_state':
> return self._wrapped._sa_instance_state
> old_session = object_session(self._wrapped)
> new_session = api.get_session()
> with self._lock:
> if old_session is not new_session:
> self._wrapped = new_session.merge(self._wrapped)
> value = getattr(self._wrapped, name)
> setattr(self, name, value)
> return value
>
> class XQuery(query.Query):
> def __init__(self, wrapper_cls, entities, session=None):
> super(XQuery, self).__init__(entities, session=session)
> self._wrapper_cls = wrapper_cls
> def instances(self, cursor, context):
> for cursor in super(XQuery, self).instances(cursor, context):
> yield self._wrapper_cls(cursor)
>
> WrapperQuery = functools.partial(XQuery, Wrapper)
> MemoizeWrapperQuery = functools.partial(XQuery, MemoizeWrapper)
>

Is it the right way ?
Will it be more elegant by customizing the declarative_base() ? 

-- 
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/-/-I8SiXWqkk8J.
To post to this group, send email to sqlalchemy@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.



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

2012-03-09 Thread Randy Syring
I checked out that function and it turns out that I actually do have 
problems with:


q = db.sess.query(Blog).filter(Blog.title == u'foo').limit(10).offset(5)

results in:

SELECT blogs.id, blogs.createdts, blogs.updatedts, blogs.title, blogs.ident
FROM blogs
WHERE blogs.title = ?
 LIMIT ? OFFSET ?

However, I was mistaken in my original post.  The problem was not with 
the helper function but with the way I was doing my testing.  The full 
implementation of the helper function is here:


http://stackoverflow.com/a/5698357/182111

-
Randy Syring
Development&  Executive Director
Level 12 Technologies    (formerly Intelicom)
Direct: 502-276-0459
Office: 502-212-9913

Intelicom is now Level 12 Technologies,learn more about our name change  
.
Please update your address book with my new email address.

Principled People, Technology that Works


On 03/09/2012 03:25 AM, Alex K wrote:

We use this recipe and in 0.7.5 it works ok with limit and offset.

http://www.sqlalchemy.org/trac/wiki/UsageRecipes/old/DebugInlineParams


On Fri, Mar 9, 2012 at 10:32 AM, Randy Syring > wrote:


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 and it would appear this recipe
does not handle LIMIT/OFFSET becoming parameterized.  I get the
following when using the function:

"...persons.last_name AS persons_last_name FROM persons LIMIT
:param_1 OFFSET :param_2"

I'm in over my head on SA internals on this one and would
appreciate suggestions.

Thanks in advance.
-- 
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/-/ryYu6nVG-RQJ.
To post to this group, send email to sqlalchemy@googlegroups.com
.
To unsubscribe from this group, send email to
sqlalchemy+unsubscr...@googlegroups.com
.
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en.


--
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 unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.


--
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 unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.



[sqlalchemy] Using expression language to create temporary tables

2012-03-09 Thread Sharon
Greetings:

Just started looking at SqlAlchemy as we may want to use its sql expression 
language to abstract our (sometimes) database specific sql. 

To create a temporary table in postgresql we would typically do something 
like this:

SELECT m._marker_key, m.symbol
INTO TEMPORARY TABLE tmp_markers
FROM mrk_marker m
WHERE m._organism_key == 1
AND m._marker_status_key IN (1,3)
  
To do this using sqlalchemy I have done the following, see below. I don't 
see a way to SELECT INTO using sqlalchemy. Is there a simpler way? Thanks 
for your help!!

# create the temporary table
tmp_markers = Table('tmp_markers', metadata,
Column('_marker_key', Integer, index=True),
Column('symbol', String(50) ),
prefixes=['TEMPORARY']
)
tmp_markers.create()

# create the connection after create the temporary table
connection = engine.connect()

# Query with which to load 'tmp_markers'
query = select([m.c._marker_key, m.c.symbol],
   and_ (
m.c._organism_key == 1,
m.c._marker_status_key.in_([1,3]),
)
)

# execute the query
results = connection.execute(query)

# create the insert expression
ins_tmp = tmp_markers.insert()

# create list of results to insert into 'tmp_markers'
ins_tmp_list = []
for r in results:
ins_tmp_list.append({
'_marker_key':  r[m.c._marker_key],
'symbol':   r[m.c.symbol],
})
results.close()

# insert into 'tmp_markers'
connection.execute(ins_tmp, ins_tmp_list)



-- 
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/-/B8Umq9y08EoJ.
To post to this group, send email to sqlalchemy@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.



[sqlalchemy] Re: complex update query

2012-03-09 Thread yannack
Amazing reply! thanks a lot Mike, as usual, top notch :)

On Thursday, March 8, 2012 11:33:55 AM UTC+1, yannack wrote:
>
> 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, index=True) 
> extra_scorecard_id = Column(Integer, 
> ForeignKey("scraper_scorecard.id"), index=True) 
> extra_scorecard = relationship(ScoreCard, 
> primaryjoin="Scoring.extra_scorecard_id==ScoreCard.scorecard_id") 
> weekstart = Column(Date, index=True) 
> extra_rank = Column(Integer, index=True) 
> [...] 
>
> class ScoreCard(Base): 
> __tablename__ = 'scraper_scorecard' 
> scorecard_id=Column('id',Integer, primary_key=True) 
> player_index = Column(Float) 
> [...] 
>
> I have a way of calculating the Scoring.extra value for a given 
> weekstart. 
> I can calculate the ranks of the scorings for a given weekstart in the 
> following way (SQL): 
> select scraper_scoring.*, player_index, rank() over(order by extra 
> asc, player_index desc) as rank from scraper_scoring join 
> scraper_scorecard on extra_scorecard_id=scraper_scorecard.id where 
> weekstart=%s order by extra asc, player_index desc 
>
> I would then like to store the ranks of all the scorings in the 
> following way: 
> update scraper_scoring set extra_rank=ordered_table.rank from (select 
> scraper_scoring.*, player_index, rank() over(order by extra asc, 
> player_index desc) as rank from scraper_scoring join scraper_scorecard 
> on extra_scorecard_id=scraper_scorecard.id where weekstart=%s order by 
> extra asc, player_index desc) as ordered_table where 
> scraper_scoring.id=ordered_table.id; 
>
> I would like to write this in a sensible SQLA-oriented way, but I seem 
> to face various challenges; anyone have an idea how to: 
> - use PGSQL window functions 
> - update using a custom "from" clause: can I use my models here or do 
> I have to use an expression? 
> - do both at once 
> Thanks a lot, 
> best regards, 
> Yannick


On Thursday, March 8, 2012 11:33:55 AM UTC+1, yannack wrote:
>
> 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, index=True) 
> extra_scorecard_id = Column(Integer, 
> ForeignKey("scraper_scorecard.id"), index=True) 
> extra_scorecard = relationship(ScoreCard, 
> primaryjoin="Scoring.extra_scorecard_id==ScoreCard.scorecard_id") 
> weekstart = Column(Date, index=True) 
> extra_rank = Column(Integer, index=True) 
> [...] 
>
> class ScoreCard(Base): 
> __tablename__ = 'scraper_scorecard' 
> scorecard_id=Column('id',Integer, primary_key=True) 
> player_index = Column(Float) 
> [...] 
>
> I have a way of calculating the Scoring.extra value for a given 
> weekstart. 
> I can calculate the ranks of the scorings for a given weekstart in the 
> following way (SQL): 
> select scraper_scoring.*, player_index, rank() over(order by extra 
> asc, player_index desc) as rank from scraper_scoring join 
> scraper_scorecard on extra_scorecard_id=scraper_scorecard.id where 
> weekstart=%s order by extra asc, player_index desc 
>
> I would then like to store the ranks of all the scorings in the 
> following way: 
> update scraper_scoring set extra_rank=ordered_table.rank from (select 
> scraper_scoring.*, player_index, rank() over(order by extra asc, 
> player_index desc) as rank from scraper_scoring join scraper_scorecard 
> on extra_scorecard_id=scraper_scorecard.id where weekstart=%s order by 
> extra asc, player_index desc) as ordered_table where 
> scraper_scoring.id=ordered_table.id; 
>
> I would like to write this in a sensible SQLA-oriented way, but I seem 
> to face various challenges; anyone have an idea how to: 
> - use PGSQL window functions 
> - update using a custom "from" clause: can I use my models here or do 
> I have to use an expression? 
> - do both at once 
> Thanks a lot, 
> best regards, 
> Yannick

-- 
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/-/aWim15K-xm8J.
To post to this group, send email to sqlalchemy@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.



[sqlalchemy] Attribute modified but object not in session.dirty

2012-03-09 Thread Andrea
Hi all,
at http://pastebin.com/jYsZwj10 an extract of my code.
I create a custom type HexString that extends TypeDecorator. When I
modify an
object of this type on a persisted instance, changes don't affect
session.
I need some help, tnx.

Andrea

-- 
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 unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.



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

2012-03-09 Thread Randy Syring

Excellent, thank you!

-
Randy Syring
Development&  Executive Director
Level 12 Technologies    (formerly Intelicom)
Direct: 502-276-0459
Office: 502-212-9913

Intelicom is now Level 12 Technologies,learn more about our name change  
.
Please update your address book with my new email address.

Principled People, Technology that Works


On 03/09/2012 03:25 AM, Alex K wrote:

We use this recipe and in 0.7.5 it works ok with limit and offset.

http://www.sqlalchemy.org/trac/wiki/UsageRecipes/old/DebugInlineParams


On Fri, Mar 9, 2012 at 10:32 AM, Randy Syring > wrote:


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 and it would appear this recipe
does not handle LIMIT/OFFSET becoming parameterized.  I get the
following when using the function:

"...persons.last_name AS persons_last_name FROM persons LIMIT
:param_1 OFFSET :param_2"

I'm in over my head on SA internals on this one and would
appreciate suggestions.

Thanks in advance.
-- 
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/-/ryYu6nVG-RQJ.
To post to this group, send email to sqlalchemy@googlegroups.com
.
To unsubscribe from this group, send email to
sqlalchemy+unsubscr...@googlegroups.com
.
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en.


--
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 unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.


--
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 unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.



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

2012-03-09 Thread Alex K
We use this recipe and in 0.7.5 it works ok with limit and offset.

http://www.sqlalchemy.org/trac/wiki/UsageRecipes/old/DebugInlineParams


On Fri, Mar 9, 2012 at 10:32 AM, Randy Syring  wrote:

> 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 and it would appear this recipe does not
> handle LIMIT/OFFSET becoming parameterized.  I get the following when using
> the function:
>
> "...persons.last_name AS persons_last_name FROM persons LIMIT :param_1
> OFFSET :param_2"
>
> I'm in over my head on SA internals on this one and would appreciate
> suggestions.
>
> Thanks in advance.
>
> --
> 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/-/ryYu6nVG-RQJ.
> To post to this group, send email to sqlalchemy@googlegroups.com.
> To unsubscribe from this group, send email to
> sqlalchemy+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/sqlalchemy?hl=en.
>

-- 
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 unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.