[sqlalchemy] Re: in not implemented for queries?

2008-05-21 Thread az
what u want to accomplish? looks like u need one of the .any(..) or .has(..), check those also. or do u need a plain join? On Wednesday 21 May 2008 07:50, andrew cooke wrote: Hi, Just wanted to check: I am seeing a NotImplementedError (v 0.4.6 on Linux w Python 2.5) when I try to query some

[sqlalchemy] Re: 64-bit postgres produces: This SchemaItem is not connected to any Engine

2008-05-21 Thread robert rottermann
jason kirtland schrieb: robert rottermann wrote: thanks jason, jason kirtland schrieb: robert rottermann wrote: Hi there, I am building a zope/plone site that uses sqlalchemy (collective.lead). on two systems I am developping on everything works fine, a third one that

[sqlalchemy] Re: in not implemented for queries?

2008-05-21 Thread andrew cooke
On May 21, 2:04 am, [EMAIL PROTECTED] wrote: what u want to accomplish? Well, it's the equivalent of the SQL IN. So i want to retrieve all Measurements which are associated with with a Time Series in the given list. The SQL equivalent would be something like: SELECT * from Measurement as M

[sqlalchemy] Re: in not implemented for queries?

2008-05-21 Thread Michael Bayer
On May 21, 2008, at 12:50 AM, andrew cooke wrote: Hi, Just wanted to check: I am seeing a NotImplementedError (v 0.4.6 on Linux w Python 2.5) when I try to query some objects with the filter in. Does that mean that the feature is not implemented, or is it more likely an error in my

[sqlalchemy] Re: existing database/hibernating

2008-05-21 Thread Gregor Kling
Michael Bayer wrote: On May 20, 2008, at 12:15 PM, Gregor Kling wrote: its not going to work if you create the mapper() (and Table) per class instance (i.e. within __init__), It was a typo. It should be all SrvDomainTable. But why shouldn't it work, I already do the test and it does. Could

[sqlalchemy] Re: existing database/hibernating

2008-05-21 Thread Gregor Kling
Gregor Kling wrote: Michael Bayer wrote: On May 20, 2008, at 12:15 PM, Gregor Kling wrote: its not going to work if you create the mapper() (and Table) per class instance (i.e. within __init__), It was a typo. It should be all SrvDomainTable. But why shouldn't it work, I already do the

[sqlalchemy] Re: in not implemented for queries?

2008-05-21 Thread andrew cooke
On May 21, 9:37 am, Michael Bayer [EMAIL PROTECTED] wrote: in_ is supported for column-based attributes. If you are getting NotImplemented, that's beacuse time_series is referencing either a collection or a many-to-one object reference. so SQL IN wouldn't work here.For the many-to-one

[sqlalchemy] Dropping Python 2.3 Support in SQLA 0.5

2008-05-21 Thread Michael Bayer
Hey list - I'm pretty antsy to start putting out alpha releases of 0.5. One of the only things left to do for alpha-level is to decide on losing Python 2.3 support, which all of us are pretty much ready to do. We've mentioned it before and have not had any pleas for a stay of

[sqlalchemy] 0.3 -- 0.4 : dictionaries for execute()

2008-05-21 Thread Moshe C.
This is probably very simple, but I am searching the docs and not finding the answer :-( In 0.3 I had a working statement of the form: engine.execute(table.select(), cond_dict) where cond_dict is a dictionary of column names mapped to values. In 0.4.6 this does not work. What is produced in SQL

[sqlalchemy] Re: SqlAlchemy and Stored Procedures with variables

2008-05-21 Thread Paul Johnston
Hi, I thought the original impetus for scope_identity was not multiple execution contexts, but rather things being fouled up for some users where they had nested INSERTs being done via a trigger on the mapped table, and the brain-dead SELECT @@identity_insert wasn't able to pluck out the

[sqlalchemy] Re: 0.3 -- 0.4 : dictionaries for execute()

2008-05-21 Thread Michael Bayer
On May 21, 2008, at 11:06 AM, Moshe C. wrote: This is probably very simple, but I am searching the docs and not finding the answer :-( In 0.3 I had a working statement of the form: engine.execute(table.select(), cond_dict) where cond_dict is a dictionary of column names mapped to values.

[sqlalchemy] Merging output of several queries?

2008-05-21 Thread Kirk Strauser
I'm developing a Django site that uses a lot of pre-existing SQLAlchemy tables to generate reports, etc. I'm trying to get my head around the best way to programmatically generate some fairly complex queries. For instance, our users may have several roles assigned to them, and the data

[sqlalchemy] Re: 0.3 -- 0.4 : dictionaries for execute()

2008-05-21 Thread Moshe C.
Thanks. So I guess you cannot use the dictionary argument as is. It was very convenient. On May 21, 6:16 pm, Michael Bayer [EMAIL PROTECTED] wrote: On May 21, 2008, at 11:06 AM, Moshe C. wrote: This is probably very simple, but I am searching the docs and not finding the answer :-( In

[sqlalchemy] Re: 0.3 -- 0.4 : dictionaries for execute()

2008-05-21 Thread Michael Bayer
On May 21, 2008, at 11:37 AM, Moshe C. wrote: Thanks. So I guess you cannot use the dictionary argument as is. It was very convenient. It greatly complicated statement compilation since the cond_dict needed to be sent along to the compilation of table.select(), where extra logic kicked

[sqlalchemy] method to retrieve selectable columns

2008-05-21 Thread vkuznet
Hi, is there any way to ask select object what is suppose to select? There is a method locate_all_froms which return FROM part of select, but I'm interesting in select part of SQL statement. So, something like: s = select([table1.c.a,table2.c.b]) listOfSelectedColumns =

[sqlalchemy] Using multiple filter()s with contains() in a query

2008-05-21 Thread Bobby Impollonia
Hi. If I have a many-to-many relation between Class1 and Class2, the following query: Class1.query.filter(Class1.class2s.contains(obj1)).filter(Class1.class2s.contains(obj2)) , where obj1 and obj2 are instances of Class2, generates the following sql in .4.6: SELECT lots of columns FROM class1,

[sqlalchemy] AssertionError: Dependency rule tried to blank-out primary key column with Elixir

2008-05-21 Thread kremlan
I've posted the following question on the Elixir group and they sent me here. My setup ## # Tables ## roles = Table('roles', meta, Column('id', Integer, primary_key=True), Column('name', String(25)) ) users = Table('users', meta, Column('id', Integer, primary_key=True),

[sqlalchemy] Re: method to retrieve selectable columns

2008-05-21 Thread Michael Bayer
calling inner_columns() on the select() returns what actually gets rendered. The exported columns, i.e. those which you'd use when using the select() as a subquery, are accessible via the .c. attribute on the select() which has a dictionary interface. On May 21, 2008, at 12:01 PM,

[sqlalchemy] Re: Using multiple filter()s with contains() in a query

2008-05-21 Thread Michael Bayer
this might be a bug introduced in 0.4.6, it would be helpful if you could post a full test case as a trac ticket. Though im not sure how this would have worked in 0.4.5 either since I don't think we have any coverage for this exact scenario and there wasn't any aliasing logic removed

[sqlalchemy] Re: AssertionError: Dependency rule tried to blank-out primary key column with Elixir

2008-05-21 Thread Michael Bayer
you need to set cascade='all, delete-orphan' on the relation referencing the AssociationProxy.Some docs on ORM cascades are in the ORM tutorial as well as http://www.sqlalchemy.org/docs/04/session.html#unitofwork_cascades . On May 21, 2008, at 12:14 PM, kremlan wrote: I've

[sqlalchemy] Re: method to retrieve selectable columns

2008-05-21 Thread vkuznet
it doesn't seem to work for me, I just did two print statements print type(query) print query.inner_columns() and got the following traceback class 'sqlalchemy.sql.expression.Select' Traceback (most recent call last): print query.inner_columns() TypeError: 'generator' object is not callable

[sqlalchemy] Re: method to retrieve selectable columns

2008-05-21 Thread Michael Bayer
sorry, its a property. call list(select.inner_columns) On May 21, 2008, at 12:59 PM, vkuznet wrote: it doesn't seem to work for me, I just did two print statements print type(query) print query.inner_columns() and got the following traceback class 'sqlalchemy.sql.expression.Select'

[sqlalchemy] Re: Using multiple filter()s with contains() in a query

2008-05-21 Thread Bobby Impollonia
http://www.sqlalchemy.org/trac/ticket/1058 I found the query I had that worked with .4.5 and it is different because it is using not_ on each contains() which generates separate subselects (with Exists), so that doesn't have aliasing problems. That still works in .4.6. On Wed, May 21, 2008 at

[sqlalchemy] Re: ShardedSession and id_chooser

2008-05-21 Thread Kyle Schaffrick
On Tue, 20 May 2008 18:10:31 -0700 (PDT) Marcus Cavanaugh [EMAIL PROTECTED] wrote: I've read the ShardedSession docs a few times. The shard_chooser() callable is straightforward, and thanks to the example [1], I think I understand how to use query_chooser(); but I need a pointer about how to

[sqlalchemy] Re: Merging output of several queries?

2008-05-21 Thread az
i have asked about similar thing (e.g. some filter_or construct) and there's nothing so far that can do ORs or UNIONs - or any other query arithmetics except AND. See that thread (last week), there were some workarounding suggestions, using left outer join or so. On Wednesday 21 May 2008

[sqlalchemy] BLOB/TEXT column used in key specification without a key length

2008-05-21 Thread Samuel
Hi, I am migrating a project from SA 0.3 to SA 0.4 and the following field/ index produces an error: sa.Table('resource_path', self.db_metadata, sa.Column('id', sa.Integer, primary_key = True), sa.Column('path', sa.Binary(255), index = True),

[sqlalchemy] Inserting custom functions / Sorting Mixed-case fields

2008-05-21 Thread EricHolmberg
I'm doing a query and would like to order the results in alphabetical order. However, the column used is mixed case, so the results have all lower-case strings before the upper-case variables. In SQL, I would fix this by using the lower() function such as: TABLE data ( strName TEXT() NOT NULL

[sqlalchemy] Re: Inserting custom functions / Sorting Mixed-case fields

2008-05-21 Thread Michael Bayer
On May 21, 2008, at 5:06 PM, EricHolmberg wrote: I'm doing a query and would like to order the results in alphabetical order. However, the column used is mixed case, so the results have all lower-case strings before the upper-case variables. In SQL, I would fix this by using the lower()

[sqlalchemy] Re: Inserting custom functions / Sorting Mixed-case fields

2008-05-21 Thread EricHolmberg
# How do I apply the lower(field) function to the strName column? rows = model.data.query().order_by(strName).all( query.order_by(func.lower(strName)) Thanks Michael - you're a life saver! Somehow, I seemed to have missed the entire section on sqlalchemy.sql.func. For anybody else in the

[sqlalchemy] sqlalchemy decides to pull entire table

2008-05-21 Thread arashf
I'm running this query: q = Event.query.filter(and_(Event.id id_under, Event.feed == True, Event.ns_id.in_(ns_list))).limit(num).order_by([Event.updated.desc(), Event.id.desc()]) For some reason, sqlalchemy decides to pull the entire table, yet, when I don't include Event.id id_under, it

[sqlalchemy] Re: sqlalchemy decides to pull entire table

2008-05-21 Thread Rick Morrison
The and_ function is expecting two arguments, not a series of *args. It works when you remove the third argument because you then have the expected two arguments. Either use nested calls to and_, or multiple calls to filter(), and build up the query in a generative fashion, like this:

[sqlalchemy] Re: SqlAlchemy and Stored Procedures with variables

2008-05-21 Thread Rick Morrison
You're right, that was the original motivation. I tried just changing @@identity for scope_identity(), which worked just fine on pymssql, but not on the other adapters. Did eventually get it working, but it involved pyodbc changes, that I was unable to do. Fortunately someone on the list

[sqlalchemy] Re: sqlalchemy decides to pull entire table

2008-05-21 Thread arashf
hmm, I switched from 3 args to 2 and am still having the same issue. On May 21, 5:13 pm, Rick Morrison [EMAIL PROTECTED] wrote: The and_ function is expecting two arguments, not a series of *args. It works when you remove the third argument because you then have the expected two arguments.