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

2008-05-22 Thread Samuel
Additional note: The same thing happens when using Index() explicitly. --~--~-~--~~~---~--~~ 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

[sqlalchemy] Re: Using a non-primary key as ORM identifier

2008-05-22 Thread Rick Morrison
Have you considered using a discriminator column, an additional integer that identifies the shard and is part of a two-integer primary key? You could then use concrete polymorphic inheritance to set up mappers for both tables that would automatically set the discriminator column to the

[sqlalchemy] Re: sqlalchemy decides to pull entire table

2008-05-22 Thread Michael Bayer
On May 21, 2008, at 8:13 PM, Rick Morrison 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. and_() and or_() still take *args.

[sqlalchemy] Re: sqlalchemy decides to pull entire table

2008-05-22 Thread Michael Bayer
On May 21, 2008, at 7:42 PM, arashf wrote: 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,

[sqlalchemy] Re: Using a non-primary key as ORM identifier

2008-05-22 Thread Michael Bayer
On May 22, 2008, at 7:10 AM, Geoff wrote: Hi, I have split up my database horizontally and am using UUIDs to uniquely identify a row across databases. Using UUIDs as a primary key is slow (InnoDB) so I wanted to use the common trick of having a INT primary key using auto_increment on

[sqlalchemy] mySQL force index?

2008-05-22 Thread Geoff
Does SQLA have any mechanism to use FORCE INDEX? --~--~-~--~~~---~--~~ 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

[sqlalchemy] Re: Using a non-primary key as ORM identifier

2008-05-22 Thread Geoff
Nice, thanks for the tips guys! From what I understand, MySQL has some tasty optimisations that are used when the primary key is an int. So once it knows what primary key it's looking for (after looking in the index), it's faster to retrieve the row. On May 22, 2:50 pm, Michael Bayer [EMAIL

[sqlalchemy] Re: Connecting to an MS SQL server ?

2008-05-22 Thread TkNeo
I get the following db = create_engine('mssql://wscmsql/ws market datasql.db') File c:\python25\lib\site-packages\SQLAlchemy-0.4.5-py2.5.egg \sqlalchemy\engine\__init__.py, line 160, in create_engine return strategy.create(*args, **kwargs) File

[sqlalchemy] Re: Connecting to an MS SQL server ?

2008-05-22 Thread TkNeo
I get the following error. After this i tried installing pymssql which requires a minimum of python 2.4 and all i have is python 2.3 Any way out for us python 2.3 users ? db = create_engine('mssql://wscmsql/ws market datasql.db') File

[sqlalchemy] Re: Connecting to an MS SQL server ?

2008-05-22 Thread Michael Bayer
On May 22, 2008, at 11:25 AM, TkNeo wrote: I get the following error. After this i tried installing pymssql which requires a minimum of python 2.4 and all i have is python 2.3 Any way out for us python 2.3 users ? why cant you get onto py2.5 ?

[sqlalchemy] from_statement doesn't apply convert_unicode

2008-05-22 Thread Geoff
Any know why results from using from_statement do not convert strings? It works fine when I use filter_by etc... --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email

[sqlalchemy] Re: from_statement doesn't apply convert_unicode

2008-05-22 Thread Michael Bayer
assuming you're talking about inbound parameters, not result setsuse bind parameters with from_statement, in conjunction with query.params(): query.from_statement(text(select * from table where x =:y)).values(y=5).all() On May 22, 2008, at 11:57 AM, Geoff wrote: Any know why

[sqlalchemy] Re: from_statement doesn't apply convert_unicode

2008-05-22 Thread Michael Bayer
On May 22, 2008, at 12:03 PM, Michael Bayer wrote: assuming you're talking about inbound parameters, not result setsuse bind parameters with from_statement, in conjunction with query.params(): query.from_statement(text(select * from table where x =:y)).values(y=5).all() sorry, i

[sqlalchemy] Using select clause for column default

2008-05-22 Thread askel
Hello everybody, I'm having hard time figuring out how or whether it is possible at all to use select statement that can access record to be inserted as column's default value. groups = Table('groups', meta, Column('id', Integer, primary_key=True), Column('prefix', String(32),

[sqlalchemy] Re: Using select clause for column default

2008-05-22 Thread Michael Bayer
On May 22, 2008, at 12:23 PM, askel wrote: Hello everybody, I'm having hard time figuring out how or whether it is possible at all to use select statement that can access record to be inserted as column's default value. groups = Table('groups', meta, Column('id', Integer,

[sqlalchemy] Re: Connecting to an MS SQL server ?

2008-05-22 Thread TkNeo
manager. you know how it is... i waste a lot of time , as you can see, because of being stuck to 2.3 and half the libraries out there are for 2.4 onwards. I think one day they will realize this and let me upgrade. so there is no way out for us 2.3 users... On May 22, 10:38 am, Michael

[sqlalchemy] Re: Using select clause for column default

2008-05-22 Thread askel
Thank you Michael On May 22, 12:37 pm, Michael Bayer [EMAIL PROTECTED] wrote: On May 22, 2008, at 12:23 PM, askel wrote: Hello everybody, I'm having hard time figuring out how or whether it is possible at all to use select statement that can access record to be inserted as

[sqlalchemy] Re: Using select clause for column default

2008-05-22 Thread askel
I implemented it the way Michael suggested. Now, I'm wondering if it can be done as a subquery, i.e. avoiding pre-execution of select clause. May be that is pretty much SQL engine specific but so are sequences and foreign keys. Resulting query built by compiler should be like the following:

[sqlalchemy] how to represent this?

2008-05-22 Thread az
hi object A has 2 columns, x and y. From all the A instances, for each distinct x, i want to get the instance that has maximum y. (it's a temporal query, x is obj_id, y is time - yielding the latest version of all the objects) so far i invented this sql: select a.* from a,

[sqlalchemy] join two selects

2008-05-22 Thread Jeff Putsch
Howdy, I've got this SQL query: select * from ( select a1.domain_id as domain_id_1, u1.eid as eid, u1.uname as uname, u1.uid as uid, a1.gcos, a1.home, a1.shell from nis_accounts a1 inner join nis_users u1 on (a1.nis_user_id = u1.id) where u1.eid != '' ) ndu1 inner join ( select

[sqlalchemy] Re: join two selects

2008-05-22 Thread Michael Bayer
On May 22, 2008, at 5:51 PM, Jeff Putsch wrote: Which can give me two selects using aliases: a1 = s.correlate(None).alias() a2 = s.correlate(None).alias() But every attempt at using a1 and a2 in a select with a join is failing for me. a1.join(a2, onclause) should do it. if not, supply

[sqlalchemy] foreign_keys and _local_remote_pairs problem in relation

2008-05-22 Thread kremlan
I have the following setup: (relevant excerpts only) contacts = Table('contacts', meta, Column('id', Integer, primary_key=True), Column('display_as', String(75)), Column('title', String(5)), Column('first_name', String(25)), Column('middle_name', String(25)),

[sqlalchemy] Re: foreign_keys and _local_remote_pairs problem in relation

2008-05-22 Thread Michael Bayer
On May 22, 2008, at 6:10 PM, kremlan wrote: I have the following setup: (relevant excerpts only) contacts = Table('contacts', meta, Column('id', Integer, primary_key=True), Column('display_as', String(75)), Column('title', String(5)), Column('first_name', String(25)),

[sqlalchemy] Re: join two selects

2008-05-22 Thread Jeff Putsch
On May 22, 2008, at 3:08 PM, Michael Bayer wrote: a1.join(a2, onclause) should do it. if not, supply a full test case and a description of the specific problem. OK, I guess. So how do I see the SQL that gets generated? I've tried this: print select(from_obj=[a1.join(a2), a1.c.eid ==

[sqlalchemy] Re: foreign_keys and _local_remote_pairs problem in relation

2008-05-22 Thread kremlan
Worked like a charm. Thank you for such a prompt reply and for the project in general. -brad On May 22, 6:36 pm, Michael Bayer [EMAIL PROTECTED] wrote: On May 22, 2008, at 6:10 PM, kremlan wrote: I have the following setup: (relevant excerpts only) contacts = Table('contacts',

[sqlalchemy] Re: join two selects

2008-05-22 Thread Jeff Putsch
I apologize for this second, longer, more detailed, post, but I thought my first response to the request for more descriptions was incomplete... On May 22, 3:08 pm, Michael Bayer [EMAIL PROTECTED] wrote: a1.join(a2, onclause) should do it.  if not, supply a full test case   and a description

[sqlalchemy] Re: Possible quoting bug, SQLite? If not, what wrong (please)?

2008-05-22 Thread Michael Bayer
label() is quoting isnull because isnull is listed as a reserved word. literal_column(isnull) is not, because literal_column does exactly what you say. So id try first not using the word isnull for the label. After that, its possible that SQlite isnt going to let you allow ordering by

[sqlalchemy] Re: Possible quoting bug, SQLite? If not, what wrong (please)?

2008-05-22 Thread andrew cooke
1 - changing isnull to foo worked. thanks! 2 - i tried adding text('nulls last') in the order_by(...), but got an error from sqlite. i don't suppose there's something clever in sqlalchemy that does this in a portable way is there? 3 - what do you use as a reference for SQL? do you have the

[sqlalchemy] Re: Possible quoting bug, SQLite? If not, what wrong (please)?

2008-05-22 Thread andrew cooke
the case solution works too, which is what i'll go with. thanks. --~--~-~--~~~---~--~~ 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

[sqlalchemy] Direct execute of postgres COPY

2008-05-22 Thread schickb
I'm brand new to SA, and trying to import data from a text file by directly executing postgresql's COPY statement. It works fine in the postgresql client (psql), but when I run the same statements through SA I get an empty table. This is a snip of the python code: dbengine =