[sqlalchemy] Combining joined and single table inheritance

2008-05-09 Thread "Fernando Zunino"
Hi, is it possible to combine joined and single table inheritance in the same inheritance hierarchy? In the code at the bottom I want to use the persons table as a base for the Person, Employee and Manager classes and the employees table to store the particular fields of Employee and Manager. I'

[sqlalchemy] Re: Problem with non-null fields

2008-05-09 Thread TP
Who knew that marking a field as non-null didn't really make it non- null? Apparently you have to add the following to your my.cnf to tell MySQL your're actually serious about enforcing things: sql-mode='STRICT_TRANS_TABLES' On May 9, 11:30 am, jason kirtland <[EMAIL PROTECTED]> wrote: > TP wrot

[sqlalchemy] Re: Insert-or-update pattern

2008-05-09 Thread Michael Bayer
On May 9, 2008, at 12:02 PM, David Turner wrote: > > page = Page (url = url, body = body) > Session.insert_or_update(page) > Session.commit() > > Is this functionality there, and I just don't understand it? here is the usual way: page = Session.query(Page).filter(Page.url == url, Page.bo

[sqlalchemy] Re: Result Set From An Oracle Function

2008-05-09 Thread Michael Bayer
On May 9, 2008, at 10:20 AM, Dan wrote: > > Not sure how to do it otherwise. This is how its been coded -- what > is the alternative? what happens if you just say, cursor.execute("select * from aaa_test(pWhen=>:arg1", {'arg1':None}) using raw cx_oracle (and then cursor.fetchall()) ? do

[sqlalchemy] Insert-or-update pattern

2008-05-09 Thread David Turner
Here's a pattern that I see a lot that SQLAlchemy doesn't really seem to support: update a row if it exists, or insert it if it doesn't. Imagine you're writing a web spider, so you've got a table with a primary key of the URL, with another column for the page's body. Your spider comes across a p

[sqlalchemy] Re: Problem with non-null fields

2008-05-09 Thread jason kirtland
TP wrote: > Hi, I have a model with a field called 'name' that is set to be non- > null. When I look at the actual table created in MySQL the field > really does say it cannot be null. However, when I try to set it to > None and commit() the changes, I get a warning printed > > /Users/tp/sw/pytho

[sqlalchemy] Re: The IN Construct

2008-05-09 Thread Bobby Impollonia
in_ is a method that exists on a column. You pass it the list of things that the column value should be in. For example, if you have a class called MyClass that is mapped to a table and has a column called id, you can do: session.query(MyClass).filter(MyClass.id.in_( [ 3, 4] )).all() On Fri, Ma

[sqlalchemy] The IN Construct

2008-05-09 Thread Googli S
Hello, I would like to use the IN construct in one of my queries: i.e. WHERE c.id IN (..subquery here) But I can't find any sqlalchemy support for It. It's hvery hard to search for :( Anyone know? Thanks --~--~-~--~~~---~--~~ You received this message beca

[sqlalchemy] Re: Result Set From An Oracle Function

2008-05-09 Thread Dan
Not sure how to do it otherwise. This is how its been coded -- what is the alternative? On May 9, 8:34 am, Michael Bayer <[EMAIL PROTECTED]> wrote: > On May 9, 2008, at 4:26 AM, Dan wrote: > > > > > > > Using cx_Oracle, the following does the trick (note this is a > > contrived example): > > > d

[sqlalchemy] Re: database definitions - was sqlalchemy migration/schema creation

2008-05-09 Thread az
On Friday 09 May 2008 16:32:25 Lukasz Szybalski wrote: > On Fri, May 9, 2008 at 4:46 AM, <[EMAIL PROTECTED]> wrote: > > On Friday 09 May 2008 03:05, Lukasz Szybalski wrote: > >> Do you guys know what would give me column definition of table? > > > > do u want it as generated source-text or what?

[sqlalchemy] Re: Result Set From An Oracle Function

2008-05-09 Thread Michael Bayer
On May 9, 2008, at 4:26 AM, Dan wrote: > > Using cx_Oracle, the following does the trick (note this is a > contrived example): > > def test(orcl_conn): > curs = orcl_conn.cursor() > cursorToBind = orcl_conn.cursor() > curs.execute("""begin > :cr1 := aaa_test(pWhen => :arg1

[sqlalchemy] Re: database definitions - was sqlalchemy migration/schema creation

2008-05-09 Thread Lukasz Szybalski
On Fri, May 9, 2008 at 4:46 AM, <[EMAIL PROTECTED]> wrote: > > On Friday 09 May 2008 03:05, Lukasz Szybalski wrote: >> Do you guys know what would give me column definition of table? > do u want it as generated source-text or what? Yes. The Final output I would like is the txt version of db defi

[sqlalchemy] Problem with non-null fields

2008-05-09 Thread TP
Hi, I have a model with a field called 'name' that is set to be non- null. When I look at the actual table created in MySQL the field really does say it cannot be null. However, when I try to set it to None and commit() the changes, I get a warning printed /Users/tp/sw/python-extensions/lib/pytho

[sqlalchemy] Re: database definitions - was sqlalchemy migration/schema creation

2008-05-09 Thread az
On Friday 09 May 2008 03:05, Lukasz Szybalski wrote: > Do you guys know what would give me column definition of table? do u want it as generated source-text or what? have a look at dbcook/dbcook/misc/metadata/autoload.py at dbcook.sf.net > I have a table that I autoload and I would like to get t

[sqlalchemy] Re: database definitions - was sqlalchemy migration/schema creation

2008-05-09 Thread Lele Gaifax
On Thu, 8 May 2008 19:05:20 -0500 "Lukasz Szybalski" <[EMAIL PROTECTED]> wrote: > Do you guys know what would give me column definition of table? There is an autocode tool that, although with some glitches on it own, does exactly what you are looking for. See http://www.sqlalchemy.org/trac/wiki

[sqlalchemy] Re: Result Set From An Oracle Function

2008-05-09 Thread Dan
Using cx_Oracle, the following does the trick (note this is a contrived example): def test(orcl_conn): curs = orcl_conn.cursor() cursorToBind = orcl_conn.cursor() curs.execute("""begin :cr1 := aaa_test(pWhen => :arg1); end;""", arg1 = None, cr1 = cur