[sqlalchemy] bad result when querying for null values (in pk at least)

2009-10-15 Thread alexbodn . groups
hello friends, thank you very much for making and contributing to this great project. i have a table with a multi-field primary key, one of which allows null. when querying this table, i don't get the records with null in that field, even if i'm specifically asking them in where. but what

[sqlalchemy] Best way to find out: outer session

2009-10-15 Thread twiebe
Hello, when building a session extension with after_rollback or (after|before) _commit logic one might want to find out whether the session that triggered the extension by issuing a rollback or commit actually is an outer session resp. actually issues/issued a COMMIT or ROLLBACK to the database,

[sqlalchemy] Re: bad result when querying for null values (in pk at least)

2009-10-15 Thread Mike Conley
add allow_null_pks to your mapper arguments See http://www.sqlalchemy.org/docs/05/reference/orm/mapping.html --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to

[sqlalchemy] Re: ORM Many to Many Across Two Databases

2009-10-15 Thread Luke Arno
My apologies. I must have misunderstanding the behavior of the schema option and thus its intent. How do I configure a relation across two logical databases using schema? I have tried the following: engine = create_engine(DATABASEURI, echo=True) meta = MetaData() meta.bind = engine left_schema

[sqlalchemy] Re: bad result when querying for null values (in pk at least)

2009-10-15 Thread alexbodn . groups
thanks a lot mike, it's working great now. but this flag should be implied if one of the primary key fields is nullable (especially since it's not nullable by default). what would you think? On Thu, Oct 15, 2009 at 14:28, Mike Conley mconl...@gmail.com wrote: add allow_null_pks to your

[sqlalchemy] Declerative Relation trouble

2009-10-15 Thread Martijn Moeling
Hi All, I am having a very bad day (or two to be honest), spending time reading error messages. I am sorry to say but the SQLALCHEMY documentation is not very helpful when using declarative_base when it is about relations.. It should be very easy for you database guy's (which I'm not,

[sqlalchemy] Re: bad result when querying for null values (in pk at least)

2009-10-15 Thread Mike Conley
On Thu, Oct 15, 2009 at 9:21 AM, alexbodn.gro...@gmail.com wrote: thanks a lot mike, it's working great now. but this flag should be implied if one of the primary key fields is nullable (especially since it's not nullable by default). what would you think? You can argue just as easily

[sqlalchemy] Re: bad result when querying for null values (in pk at least)

2009-10-15 Thread King Simon-NFHD78
-Original Message- From: sqlalchemy@googlegroups.com [mailto:sqlalch...@googlegroups.com] On Behalf Of Mike Conley Sent: 15 October 2009 14:43 To: sqlalchemy@googlegroups.com Cc: SQLElixir Subject: [sqlalchemy] Re: bad result when querying for null values (in pk at least)

[sqlalchemy] Re: Declerative Relation trouble

2009-10-15 Thread King Simon-NFHD78
-Original Message- From: sqlalchemy@googlegroups.com [mailto:sqlalch...@googlegroups.com] On Behalf Of Martijn Moeling Sent: 15 October 2009 14:42 To: sqlalchemy@googlegroups.com Subject: [sqlalchemy] Declerative Relation trouble Hi All, I am having a very bad day (or two

[sqlalchemy] Re: Declerative Relation trouble

2009-10-15 Thread Martijn Moeling
Hi Simon, (I do things a little different on the import side) Working example (very minimised): from sqlalchemy import Integer,Column,DateTime,Unicode,UnicodeText,Boolean,ForeignKey,Interval from sqlalchemy.ext.declarative import declarative_base import sqlalchemy.orm as orm Base =

[sqlalchemy] Re: Declerative Relation trouble

2009-10-15 Thread King Simon-NFHD78
-Original Message- From: sqlalchemy@googlegroups.com [mailto:sqlalch...@googlegroups.com] On Behalf Of Martijn Moeling Sent: 15 October 2009 15:38 To: sqlalchemy@googlegroups.com Subject: [sqlalchemy] Re: Declerative Relation trouble Hi Simon, (I do things a little

[sqlalchemy] Re: bad result when querying for null values (in pk at least)

2009-10-15 Thread alexbodn . groups
On Thu, Oct 15, 2009 at 15:43, Mike Conley mconl...@gmail.com wrote: On Thu, Oct 15, 2009 at 9:21 AM, alexbodn.gro...@gmail.com wrote: thanks a lot mike, it's working great now. but this flag should be implied if one of the primary key fields is nullable (especially since it's not nullable

[sqlalchemy] Re: Declerative Relation trouble

2009-10-15 Thread King Simon-NFHD78
-Original Message- From: sqlalchemy@googlegroups.com [mailto:sqlalch...@googlegroups.com] On Behalf Of Martijn Moeling Sent: 15 October 2009 15:55 To: sqlalchemy@googlegroups.com Subject: [sqlalchemy] Re: Declerative Relation trouble I downgraded SQLA to version 0.5.5, no

[sqlalchemy] Re: Declerative Relation trouble

2009-10-15 Thread Martijn Moeling
I downgraded SQLA to version 0.5.5, no luck, (Simon) what version of python are you using? On Oct 15, 2009, at 4:45 PM, Martijn Moeling wrote: Hi Simon/all, When I run your example i get: Traceback (most recent call last): File /var/www/PyWebOs/caltst.py, line 41, in module cal

[sqlalchemy] Re: bad result when querying for null values (in pk at least)

2009-10-15 Thread alexbodn . groups
On Thu, Oct 15, 2009 at 15:48, King Simon-NFHD78 simon.k...@motorola.com wrote: -Original Message- From: sqlalchemy@googlegroups.com [mailto:sqlalch...@googlegroups.com] On Behalf Of Mike Conley Sent: 15 October 2009 14:43 To: sqlalchemy@googlegroups.com Cc: SQLElixir Subject:

[sqlalchemy] Re:[runs one one installation not on the other] Declerative Relation trouble

2009-10-15 Thread Martijn Moeling
Hi All, bad problem I have trouble making relations in SQLA. My code runs on Simons computer but his (and mine) not. I downgraded SLQA from 0.5.6. to 0.5.5 to have the same version, still no luck. I run Python 2.6.2 and Simon 2.5.1 Downgrading Python is a hassle at the moment

[sqlalchemy] Re: [runs one one installation not on the other] Declerative Relation trouble

2009-10-15 Thread King Simon-NFHD78
-Original Message- From: sqlalchemy@googlegroups.com [mailto:sqlalch...@googlegroups.com] On Behalf Of Martijn Moeling Sent: 15 October 2009 16:21 To: sqlalchemy@googlegroups.com Subject: [sqlalchemy] Re:[runs one one installation not on the other] Declerative Relation trouble

[sqlalchemy] Re: [runs one one installation not on the other] Declerative Relation trouble

2009-10-15 Thread Martijn Moeling
Mod_python has nothing to do with this project, so I run it from idle within X On Oct 15, 2009, at 5:23 PM, King Simon-NFHD78 wrote: -Original Message- From: sqlalchemy@googlegroups.com [mailto:sqlalch...@googlegroups.com] On Behalf Of Martijn Moeling Sent: 15 October 2009 16:21

[sqlalchemy] Re: [runs one one installation not on the other] Declerative Relation trouble

2009-10-15 Thread King Simon-NFHD78
-Original Message- From: sqlalchemy@googlegroups.com [mailto:sqlalch...@googlegroups.com] On Behalf Of Martijn Moeling Sent: 15 October 2009 16:27 To: sqlalchemy@googlegroups.com Subject: [sqlalchemy] Re: [runs one one installation not on the other] Declerative Relation trouble

[sqlalchemy] Eager loading with SELECT instead of JOIN

2009-10-15 Thread Emil Ivanov
As far as I understand eager loading it works by adding a join clause to the select. That has the drawback of increased number or rows returned. Imagine having 100 objects and each with 200 related objects, most of which overlap so the total number of related objects is about 300. That will

[sqlalchemy] Re: [runs one one installation not on the other] Declerative Relation trouble

2009-10-15 Thread Martijn Moeling
(in the mean time I drove home. dinner soon) Indeed, running it from command line changes things, Strange since I even rebooted the machine in the process, but since I was messing with the code It could well have been really broken. Your sample works from the command line, mine still

[sqlalchemy] Re: Eager loading with SELECT instead of JOIN

2009-10-15 Thread Michael Bayer
Emil Ivanov wrote: As far as I understand eager loading it works by adding a join clause to the select. That has the drawback of increased number or rows returned. Imagine having 100 objects and each with 200 related objects, most of which overlap so the total number of related objects is

[sqlalchemy] Re: Eager loading with SELECT instead of JOIN

2009-10-15 Thread Michael Bayer
Michael Bayer wrote: Emil Ivanov wrote: As far as I understand eager loading it works by adding a join clause to the select. That has the drawback of increased number or rows returned. Imagine having 100 objects and each with 200 related objects, most of which overlap so the total number

[sqlalchemy] invalid transaction rollback etc and making a join join

2009-10-15 Thread Jeff Cook
Dear All People: I'm using SQLSoup and getting errors like InvalidRequestError: Can't reconnect until invalid transaction is rolled back and MySQL Server has gone away. I have set autoflush=True and this has helped mitigate some errors, but not these, they happen with varying frequency when I

[sqlalchemy] Re: Eager loading with SELECT instead of JOIN

2009-10-15 Thread Michael Bayer
Emil Ivanov wrote: As far as I understand eager loading it works by adding a join clause and...the rationale for the Hibernate feature is to optimize *lazy* loading, not eager loading - its a query that you only want if needed. Also hibernate does a poor job with join-based eager loading -

[sqlalchemy] Re: invalid transaction rollback etc and making a join join

2009-10-15 Thread Michael Bayer
Jeff Cook wrote: Dear All People: I'm using SQLSoup and getting errors like InvalidRequestError: Can't reconnect until invalid transaction is rolled back and MySQL Server has gone away. I have set autoflush=True and this has helped mitigate some errors, but not these, they happen with

[sqlalchemy] Re: invalid transaction rollback etc and making a join join

2009-10-15 Thread Jeff Cook
It's not faster. I use pyscopg2 directly on some other projects and it's definitely a lot faster to just be able to write the query I want than to try to think of how to convert it to SQLAlchemy's contexts and functions. Maybe it's just learning curve thing, but as shown, I can't get that join to

[sqlalchemy] Re: invalid transaction rollback etc and making a join join

2009-10-15 Thread Michael Bayer
Jeff Cook wrote: I don't fully understand what you're talking about. I have this error and I need to make it stop. I just want SQLAlchemy to connect, run the query I instructed, and give me the results back and do this reliably without necessitating consistent server restarts. Thus far, it's

[sqlalchemy] Re: invalid transaction rollback etc and making a join join

2009-10-15 Thread Jeff Cook
I see. So Pylons should handle this by default, but it's not doing so? That's highly disappointing. Clearly, something is quite incorrect here. Is my usage of SQLSoup causing rollback not to run? On Thu, Oct 15, 2009 at 1:16 PM, Michael Bayer mike...@zzzcomputing.com wrote: Jeff Cook wrote: I

[sqlalchemy] Re: invalid transaction rollback etc and making a join join

2009-10-15 Thread Jeff Cook
And when things _do_ work, there are serious caching problems. Sometimes it gives me the transaction rollback error, sometimes it gives me an old version of the page, and sometimes it gives me a current version of the page. I assume this has something to do with what connection is getting used.

[sqlalchemy] Re: Defining custom types

2009-10-15 Thread Michael Bayer
thatsanicehatyouh...@mac.com wrote: Hello, On 12 Oct 2009, at 21:04, Michael Bayer wrote: On Oct 12, 2009, at 4:26 PM, thatsanicehatyouh...@mac.com wrote: Hello, I have a custom type defined in my postgresql database, and this is giving me the warning:

[sqlalchemy] Re: sqlalchemy.sql.expression.func and composite types

2009-10-15 Thread David Gardner
Thanks for the tip about TypeDecorator I got it working to parse up the string, still not sure why SA is returning a string and not a tuple of integers, but at this point I have a good work-around and I'm happy. Especially since TypeDecorator allows me to return those numbers as a dictionary.

[sqlalchemy] Re: Defining custom types

2009-10-15 Thread thatsanicehatyouhave
Hi Michael, Thanks for clarifying that for me. For anyone interested, this is what I ended up with: from sqlalchemy import String sa_major_version = sqlalchemy.__version__[0:3] if sa_major_version == 0.5: from sqlalchemy.databases import postgres

[sqlalchemy] Re: sqlalchemy.sql.expression.func and composite types

2009-10-15 Thread Conor
David Gardner wrote: Thanks for the tip about TypeDecorator I got it working to parse up the string, still not sure why SA is returning a string and not a tuple of integers, but at this point I have a good work-around and I'm happy. Especially since TypeDecorator allows me to return those

[sqlalchemy] Do not use the idle -n command when using SQLA

2009-10-15 Thread Martijn Moeling
Ok here is the deal Since I sometimes need to run multiple instances of idle in the same shell,so I use the -n switch by default: 8 [removed~u...@removed~host ~]# idle --help Error: option --help not recognized USAGE: idle

[sqlalchemy] Re: sqlalchemy.sql.expression.func and composite types

2009-10-15 Thread David Gardner
Aha! thanks for the tip. You are right, because that is the way psql returns it. I re-wrote my PostgreSQL function to return an array of bigint, which then psycopg2 and SQLAlchemy see as an array of integers, which works out really great for me. I don't think SA is at fault: I believe that

[sqlalchemy] Re: invalid transaction rollback etc and making a join join

2009-10-15 Thread Michael Bayer
On Oct 15, 2009, at 3:32 PM, Jeff Cook wrote: And when things _do_ work, there are serious caching problems. Sometimes it gives me the transaction rollback error, sometimes it gives me an old version of the page, and sometimes it gives me a current version of the page. I assume this has

[sqlalchemy] Re: invalid transaction rollback etc and making a join join

2009-10-15 Thread Jeff Cook
OK, man, well, I have one function that has the calls to perform the listing. I refresh and sometimes get old data and sometimes don't. There is no clustering and no other databases, there is no possibility that the server is retrieving old data. I haven't changed the base Pylons classes at all,