[sqlalchemy] MultipleResultsFound

2011-03-30 Thread jose soares
Hi all, I got, for the first time the following error: ../lib/python2.6/site-packages/SQLAlchemy-0.6.0-py2.6.egg/sqlalchemy/orm/query.py, line 1417, in one Multiple rows were found for one()) MultipleResultsFound: Multiple rows were found for one() Does anyone know what that means? j

Re: [sqlalchemy] MultipleResultsFound

2011-03-30 Thread Mike Conley
You issued a query with a .one() qualifier and there is more than one row in the database satisfying the condition. Example: 2 names in a table firstname=pete, lastname=smith firstname=john, lastname=smith query for rows lastname=smith with .one() will fail because there are 2 smith in database

Re: [sqlalchemy] Re: Combine Textual query with a filter

2011-03-30 Thread Corey Coogan
Thanks again Michael. The syntax was just made up pseudo code. I was in a hurry to respond. Anyway, this worked and here's a snippet of what it looks like: sharedFilterQuery = '''WITHRECURSIVE q AS ( SELECT h.* FROMSelection.FilterFolder h join

[sqlalchemy] Truncate tables on unittest.TestCase.tearDown Hangs

2011-03-30 Thread Corey Coogan
I have a couple tables I would like to truncate when each integration test is done running. This works fine, in some cases, as long as there's exception thrown from any of the tests. In other cases, only the first test works and the others hang on the TRUNCATE call. I know it must have

Re: [sqlalchemy] MultipleResultsFound

2011-03-30 Thread jose soares
Mike Conley wrote: You issued a query with a .one() qualifier and there is more than one row in the database satisfying the condition. Example: 2 names in a table firstname=pete, lastname=smith firstname=john, lastname=smith query for rows lastname=smith with .one() will fail because there

[sqlalchemy] sqlalchemy.exc.NoReferencedTableError: Could not find table with which to generate a foreign key

2011-03-30 Thread 371c
Hi, I have the following setup: myapp.models.notes.py Note model defined here using declarative base myapp.models.users.py User model defined here using declarative base myapp.models.meta.py Base and DBSession defined here to avoid circular imports... myapp.lib.bootstrap.py Called to

[sqlalchemy] Re: Python 3.1 + SQLAlchemy 0.6 or 0.7

2011-03-30 Thread Hans-Martin
On Mar 21, 3:31 pm, Michael Bayer mike...@zzzcomputing.com wrote: Yeah psycopg2 with python 3 / sqlalchemy is not supported yet.  The python 3 supported version of psycopg2 came out like, in the past two weeks.    It will be 0.7 where its supported at all, hopefully soon as its a matter

[sqlalchemy] Re: sqlalchemy.exc.NoReferencedTableError: Could not find table with which to generate a foreign key

2011-03-30 Thread eric cire
Hi, i can actually confirm that i don't get the error when all models are in the same module. Any ideas? On Wed, Mar 30, 2011 at 3:57 PM, eric cire 371c@gmail.com wrote: After investigating further, i have the impression that the problem occurs when models are in different modules

Re: [sqlalchemy] Re: Python 3.1 + SQLAlchemy 0.6 or 0.7

2011-03-30 Thread Michael Bayer
On Mar 30, 2011, at 8:31 AM, Hans-Martin wrote: On Mar 21, 3:31 pm, Michael Bayer mike...@zzzcomputing.com wrote: Yeah psycopg2 with python 3 / sqlalchemy is not supported yet. The python 3 supported version of psycopg2 came out like, in the past two weeks.It will be 0.7 where its

RE: [sqlalchemy] Re: sqlalchemy.exc.NoReferencedTableError: Could not find table with which to generate a foreign key

2011-03-30 Thread King Simon-NFHD78
This is just the way Python works - code inside a module is only executed when that module is imported. If you don't import myapp.models.notes, then the class definitions never get executed. One solution is to import all the sub-modules in your bootstrap.py before calling create_all. Another is

[sqlalchemy] Re: sqlalchemy.exc.NoReferencedTableError: Could not find table with which to generate a foreign key

2011-03-30 Thread 371c
Actually that helps alot and i had infact resolved to and was in the process of doing so (i know that about python modules.. ;) but i might be missing something) But, why does this work in the context of an application (eg. pylons app). Basically, calling Base.create_all() in some init_db

[sqlalchemy] Re: Python 3.1 + SQLAlchemy 0.6 or 0.7

2011-03-30 Thread Hans-Martin
Sorry, I was not expecting it to work, just trying to follow your suggestion. SQLAlchemy Dev snapshot + pg8000 from http://pybrary.net/pg8000/dist/pg8000-py3-1.08.tar.gz throws this error: Traceback (most recent call last): File set_meta_info_levels_0_1.py, line 60, in module

[sqlalchemy] Re: sqlalchemy.exc.NoReferencedTableError: Could not find table with which to generate a foreign key

2011-03-30 Thread 371c
Actually that helps alot and i had infact resolved to and was in the process of doing so (i know that about python modules.. ;) but i might be missing something) But, why does this work in the context of an application (eg. pylons app). Basically, calling Base.create_all() in some init_db

RE: [sqlalchemy] Re: sqlalchemy.exc.NoReferencedTableError: Could not find table with which to generate a foreign key

2011-03-30 Thread King Simon-NFHD78
Something else must be importing those modules when run from pylons. If you really want to know how they are getting imported, stick something in the module which will raise an exception when it is imported (eg type blah blah blah at the top of the module) and look at the traceback. Cheers,

[sqlalchemy] Detect runaway query

2011-03-30 Thread Rick Morrison
Hi list: I've recently been plagued by a runaway query somewhere in one of my apps that mistakenly loads 10s of 1000's of rows, swamping the working set of the Python process and eventually invoking the OOM killer. Unfortunately, the database backend I'm using (MSSQL 2005) doesn't provide a lot

Re: [sqlalchemy] Re: Python 3.1 + SQLAlchemy 0.6 or 0.7

2011-03-30 Thread Michael Bayer
That's not an error I'm familiar with how to reproduce; it suggests an incorrect string passed to create_engine(). Working code with Python 3.2 plus pg8000 looks like: from sqlalchemy import create_engine e = create_engine(postgresql+pg8000://scott:tiger@localhost/test)

Re: [sqlalchemy] Detect runaway query

2011-03-30 Thread Michael Bayer
For quick hits I usually turn debug logging on, or echo='debug' with create_engine(), that shows the rows coming in in the log. There's no per row event interface, you can of course intercept execute events at the engine and cursor level with ConnectionProxy. A blunt approach may be to

Re: [sqlalchemy] Detect runaway query

2011-03-30 Thread Rick Morrison
Beautiful - there's plenty to work with here. Thanks much, Mike! On Wed, Mar 30, 2011 at 11:51 AM, Michael Bayer mike...@zzzcomputing.comwrote: For quick hits I usually turn debug logging on, or echo='debug' with create_engine(), that shows the rows coming in in the log. There's no per row

[sqlalchemy] Re: Python 3.1 + SQLAlchemy 0.6 or 0.7

2011-03-30 Thread Hans-Martin
On Mar 30, 5:43 pm, Michael Bayer mike...@zzzcomputing.com wrote: That's not an error I'm familiar with how to reproduce; it suggests an incorrect string passed to create_engine().   Working code with Python 3.2 plus pg8000 looks like: from sqlalchemy import create_engine e =

Re: [sqlalchemy] Re: Python 3.1 + SQLAlchemy 0.6 or 0.7

2011-03-30 Thread Michael Bayer
On Mar 30, 2011, at 12:42 PM, Hans-Martin wrote: On Mar 30, 5:43 pm, Michael Bayer mike...@zzzcomputing.com wrote: That's not an error I'm familiar with how to reproduce; it suggests an incorrect string passed to create_engine(). Working code with Python 3.2 plus pg8000 looks like:

[sqlalchemy] Re: Python 3.1 + SQLAlchemy 0.6 or 0.7

2011-03-30 Thread Hans-Martin
you'd need an @ sign in there perhaps: db://@/test Same error. But no big deal, I can wait for psycopg2 support in Python 3.2. -- 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

Re: [sqlalchemy] Re: Python 3.1 + SQLAlchemy 0.6 or 0.7

2011-03-30 Thread Michael Bayer
well its not going to work there either most likely since we don't support connecting without a hostname, probably. You can't put localhost in there ? On Mar 30, 2011, at 1:07 PM, Hans-Martin wrote: you'd need an @ sign in there perhaps: db://@/test Same error. But no big deal, I can

[sqlalchemy] Re: Python 3.1 + SQLAlchemy 0.6 or 0.7

2011-03-30 Thread Hans-Martin
On Mar 30, 7:13 pm, Michael Bayer mike...@zzzcomputing.com wrote: well its not going to work there either most likely since we don't support connecting without a hostname, probably.  You can't put localhost in there ? Doesn't work either, same error. Adding my system username (and password)

Re: [sqlalchemy] Re: Python 3.1 + SQLAlchemy 0.6 or 0.7

2011-03-30 Thread Michael Bayer
On Mar 30, 2011, at 1:39 PM, Hans-Martin wrote: On Mar 30, 7:13 pm, Michael Bayer mike...@zzzcomputing.com wrote: well its not going to work there either most likely since we don't support connecting without a hostname, probably. You can't put localhost in there ? Doesn't work either,

[sqlalchemy] Self-referencing table without Foreign-Key SQLAlchemy

2011-03-30 Thread Mene
Hello, often when you have a table with selfrefernece, say in a tree, you have an attribute as a foreign key, which is pointing to the primary key of the table. (like in the Adjacency List Relationships example from the docs) However, I have a natural key, which works like this: is the root a,

Re: [sqlalchemy] Self-referencing table without Foreign-Key SQLAlchemy

2011-03-30 Thread Michael Bayer
On Mar 30, 2011, at 2:58 PM, Mene wrote: Hello, often when you have a table with selfrefernece, say in a tree, you have an attribute as a foreign key, which is pointing to the primary key of the table. (like in the Adjacency List Relationships example from the docs) However, I have a

[sqlalchemy] Is Engine instance object threadsafe?

2011-03-30 Thread Ajay
We use sqlalchemy 0.4.6 with elixir 0.5.2 and zope. Below is some excerpt to show how we currently create/manage one engine instance per zope thread. From what I understand from reading the documentation, the 'connection' and 'transaction' objects themselves are not thread safe - but the engine

Re: [sqlalchemy] Is Engine instance object threadsafe?

2011-03-30 Thread Michael Bayer
On Mar 30, 2011, at 6:48 PM, Ajay wrote: We use sqlalchemy 0.4.6 with elixir 0.5.2 and zope. Below is some excerpt to show how we currently create/manage one engine instance per zope thread. From what I understand from reading the documentation, the 'connection' and 'transaction'