[sqlalchemy] Re: use of replace

2015-12-28 Thread Horcle
Looking for something to mimic the replace function in an SQL statement, like: Select * from Clinical where replace(Clinical.string_value, ' ' , '_') On Monday, December 28, 2015 at 11:49:38 AM UTC-6, Horcle wrote: > > I am iteratively building a complex query. For one step, I have > > a[i] =

[sqlalchemy] Re: use of replace

2015-12-28 Thread Horcle
Looking for something like: Select * from Clinical where replace(Clinical.string_value, ' ', '_') = 'value_here' On Monday, December 28, 2015 at 1:16:36 PM UTC-6, Horcle wrote: > > Or something along the lines of > > Clinical.string_value.replace(' ', '_').op... > > > > On Monday, December

[sqlalchemy] in-place modification of queries?

2015-12-28 Thread Chris Withers
Hi All, Is there anything I can do to make Query instance non-generative? query = session.query(Foo) query.filter(Foo.x==1) ...and have the query actually be modified rather than returning a new query with the clause added? cheers, Chris -- You received this message because you are

Re: [sqlalchemy] in-place modification of queries?

2015-12-28 Thread Mike Bayer
not through the current API, no. you'd need to write some modifier to the @generative decorator and basically tinker with things to make it do that. On 12/28/2015 06:18 AM, Chris Withers wrote: > Hi All, > > Is there anything I can do to make Query instance non-generative? > > query =

[sqlalchemy] Re: in-place modification of queries?

2015-12-28 Thread Lloyd Kvam
just assign to the same variable name. query = guery.filter(Foo.x == 1) The generative queries are a feature. Making the queries mutable would allow functions to modify queries and complicate debugging. You can have functions return the modified query, or have functions return the expressions

[sqlalchemy] use of replace

2015-12-28 Thread Horcle
I am iteratively building a complex query. For one step, I have a[i] = a[i].filter(Clinical.string_value.op('=')([value[i]])).subquery() I would like to simply just replace the value in Clinical.string value such that all spaces are turned into underscores. My naive approach is to do this as

[sqlalchemy] auto completion for connection and engine objects in eclipse not working

2015-12-28 Thread Krishnakant
Hello all, I need some help/ tips. This is may be perhaps partially off tipic but still it is related to Alchemy. The issue is in the subject line when I do eng = create_engine(connection_statement) I do get the engine in eng but when I do con = eng.connect I don't get any selection list when

[sqlalchemy] Re: use of replace

2015-12-28 Thread Horcle
Or something along the lines of Clinical.string_value.replace(' ', '_').op... On Monday, December 28, 2015 at 11:49:38 AM UTC-6, Horcle wrote: > > I am iteratively building a complex query. For one step, I have > > a[i] = a[i].filter(Clinical.string_value.op('=')([value[i]])).subquery() > > >

Re: [sqlalchemy] Re: use of replace

2015-12-28 Thread Mike Bayer
if you're using Postgresql you'd want to look into replace(): http://www.postgresql.org/docs/9.3/static/functions-string.html e.g. query.filter(func.replace(MyClass.column, ' ', '_') == 'some_other_value') though if 'someothervalue' is an in-Python value and your database doesn't have

Re: [sqlalchemy] Re: use of replace

2015-12-28 Thread Horcle
Using MySQL. I was missing the 'func' attribute syntax for calling this in my attempts. Works as desired. Thanks! Greg-- On Monday, December 28, 2015 at 9:19:22 PM UTC-6, Michael Bayer wrote: > > if you're using Postgresql you'd want to look into replace(): >