[sqlalchemy] Re: getting data from primary keys

2009-09-15 Thread C.T. Matsumoto
That did the trick. Thanks a lot. Your solution uses the orm sessionmaker. Till now my script was relying on sqlalchemy's expression language. Is there some way of doing the same with the expression language? Or would it get too complicated? (Just curious) Cheers, T On Mon, Sep 14, 2009 at

[sqlalchemy] Re: getting data from primary keys

2009-09-15 Thread King Simon-NFHD78
-Original Message- From: sqlalchemy@googlegroups.com [mailto:sqlalch...@googlegroups.com] On Behalf Of C.T. Matsumoto Sent: 15 September 2009 07:21 To: sqlalchemy@googlegroups.com Subject: [sqlalchemy] Re: getting data from primary keys That did the trick. Thanks a lot.

[sqlalchemy] Re: How to instantiate objects of a class mapped against multiple tables?

2009-09-15 Thread bojanb
', 'clerk')     jack = Employee('Jack', 'manager')     m1 = Meeting('20090914', peter, john)     m2 = Meeting('20090915', peter, jack)     s.add_all([john, peter, jack, m1, m2])     s.commit()     #We now want to print the names and positions of everyonePeter has ever met

[sqlalchemy] Mapping arbitrary selectables

2009-09-15 Thread Mike Conley
When mapping an arbitrary selectable, does mapper's primary_key argument need to be a primary key in the base table? Using 0.5.6, but I seem to remember same behavior in earlier versions. This works and does not generate any errors: t1 = Table('t1', meta, Column('foo', Integer,

[sqlalchemy] Re: How to instantiate objects of a class mapped against multiple tables?

2009-09-15 Thread Michael Bayer
)()     john = Employee('John', 'person')     peter = Employee('Peter', 'clerk')     jack = Employee('Jack', 'manager')     m1 = Meeting('20090914', peter, john)     m2 = Meeting('20090915', peter, jack)     s.add_all([john, peter, jack, m1, m2])     s.commit()     #We now want to print

[sqlalchemy] Re: Mapping arbitrary selectables

2009-09-15 Thread Michael Bayer
Mike Conley wrote: When mapping an arbitrary selectable, does mapper's primary_key argument need to be a primary key in the base table? Using 0.5.6, but I seem to remember same behavior in earlier versions. This works and does not generate any errors: t1 = Table('t1', meta, Column('foo',

[sqlalchemy] do I need subqueries for this?

2009-09-15 Thread Crusty
Hey everyone, sorry for the title, I couldnt think of any way to describe this in short. I have 3 Classes, which have basically this relationship: 1 Class1 has n Class2 ( 1:n) 1 Class2 has n Class3 ( 1:n) So basically it looks like this: Class1 |-- Class2 |-- Class3 Now if I

[sqlalchemy] Re: do I need subqueries for this?

2009-09-15 Thread Conor
On Sep 15, 5:38 am, Crusty crust...@gmail.com wrote: Hey everyone, sorry for the title, I couldnt think of any way to describe this in short. I have 3 Classes, which have basically this relationship: 1 Class1 has n Class2 ( 1:n) 1 Class2 has n Class3 ( 1:n) So basically it looks like

[sqlalchemy] Re: Mapping arbitrary selectables

2009-09-15 Thread Mike Conley
Submitted ticket #1542 --~--~-~--~~~---~--~~ 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 email to

[sqlalchemy] Re: Dynamic loader versus lazy=True

2009-09-15 Thread Wolodja Wentland
On Thu, Sep 10, 2009 at 23:27 +0200, Wolodja Wentland wrote: Hi all, I observed that if I define a relation (foo_query) as lazy='dynamic' and access all referenced entities with foo_query.all() that the query will be executed every time i access it. That is not a big surprise ;-) In a

[sqlalchemy] Re: Dynamic loader versus lazy=True

2009-09-15 Thread Alexandre Conrad
Keep in mind that the method on your Bar class: def all_foo(self): foo_query.all() will return a raw *list* of Foo objects. If you append more Foo objects to it, they won't be seen by SQLAlchemy's session, thus not being commited. Although, if you have set on your mapper:

[sqlalchemy] Re: Dynamic loader versus lazy=True

2009-09-15 Thread Alexandre Conrad
2009/9/10 Wolodja Wentland wentl...@cl.uni-heidelberg.de: Class Bar(object):    def all_foo(self):        foo_query.all()    def foo_startwith(self, search_string):        foo.query.filter(tbl.c.col.like('%s%%'% ...)) Note that a .startswith() method is already implemented in SA:

[sqlalchemy] query().all() OK, query().delete() can't locate bind

2009-09-15 Thread jeff.enderw...@gmail.com
I'm trying to delete in bulk using query(). query() seems to work fine: (Pdb) Session.query(TreeNode).filter(TreeNode.guid.in_ (deadNodeGuids)).all() [lajolla.main.tree.TreeNode object at 0x81c82c8c, lajolla.main.tree.TreeNode object at 0x81c8220c] But delete() is not happy: (Pdb)

[sqlalchemy] Re: How to instantiate objects of a class mapped against multiple tables?

2009-09-15 Thread bojanb
Yes, I want to map to a join between two classes which are parts of joined table inheritance. I don't think it's complex - it fits very naturally with the problem I am modeling. When I said it's efficient, I meant that the generated SQL is optimal, ie. the same as I would write if I were doing

[sqlalchemy] Re: How to instantiate objects of a class mapped against multiple tables?

2009-09-15 Thread Michael Bayer
bojanb wrote: Yes, I want to map to a join between two classes which are parts of joined table inheritance. I don't think it's complex - it fits very naturally with the problem I am modeling. When I said it's efficient, I meant that the generated SQL is optimal, ie. the same as I would

[sqlalchemy] Declarative issues, with compound foreign key

2009-09-15 Thread Gregg Lind
What I think I'm seeing is that an object can be created even without it's ForeignKeyConstraint being filled. To run the test code below: $ dropdb test18; createdb test18; python testcode.py This builds on http://groups.google.com/group/sqlalchemy/browse_thread/thread/eb240f3f2555a5e7/ . I

[sqlalchemy] relation in object mapped to select statement?

2009-09-15 Thread Bryan
The following code models a simple system that tracks the transfer of construction tools between jobs. Equip (equipment) is transferred between Jobs via Shipments. Towards the end I attempt to map a class to a select statement in order to make reporting simple. Instead of dealing with sql to

[sqlalchemy] Re: Declarative issues, with compound foreign key

2009-09-15 Thread Michael Bayer
Gregg Lind wrote: What I think I'm seeing is that an object can be created even without it's ForeignKeyConstraint being filled. To run the test code below: $ dropdb test18; createdb test18; python testcode.py on is not defined: ForeignKeyConstraint(['regstring_id',

[sqlalchemy] Re: Declarative issues, with compound foreign key

2009-09-15 Thread Conor
On Sep 15, 4:08 pm, Michael Bayer mike...@zzzcomputing.com wrote: Gregg Lind wrote: What I think I'm seeing is that an object can be created even without it's ForeignKeyConstraint being filled. To run the test code below: $ dropdb test18; createdb test18; python testcode.py on is not

[sqlalchemy] Re: Declarative issues, with compound foreign key

2009-09-15 Thread Gregg Lind
Thank you both for the advice. Dern NULLs causing trouble again. GL On Tue, Sep 15, 2009 at 4:34 PM, Conor conor.edward.da...@gmail.com wrote: On Sep 15, 4:08 pm, Michael Bayer mike...@zzzcomputing.com wrote: Gregg Lind wrote: What I think I'm seeing is that an object can be created

[sqlalchemy] intersphinx docs

2009-09-15 Thread Brett
There is a Sphinx module called intersphinx that allows API docs to be cross referenced between sites. To make it work you have to upload the objects.inv file to you web server so that when someone generates their own Sphinx-based docs it knows how to reference the remote docs. Does SQLAlchemy

[sqlalchemy] Re: intersphinx docs

2009-09-15 Thread Michael Bayer
Brett wrote: There is a Sphinx module called intersphinx that allows API docs to be cross referenced between sites. To make it work you have to upload the objects.inv file to you web server so that when someone generates their own Sphinx-based docs it knows how to reference the remote docs.

[sqlalchemy] Re: intersphinx docs

2009-09-15 Thread Brett
Sorry, I had put a . in 05 On Sep 15, 4:22 pm, Michael Bayer mike...@zzzcomputing.com wrote: Brett wrote: There is a Sphinx module called intersphinx that allows API docs to be cross referenced between sites.  To make it work you have to upload the objects.inv file to you web server so

[sqlalchemy] Declarative base - Joined Table Inheritence

2009-09-15 Thread Jarrod Chesney
Hi All I've been reading the documentation for ages and i can't figure out why when i print the results a query from my inherited table, It just prints them as the base type. I was hoping someone here would be nice enough to help me solve this problem. I thought the last print statement would

[sqlalchemy] Re: 0.55, orm, varying relation join on criteria

2009-09-15 Thread me
thanks for the (insanely fast) help! wanted to avoid doing something unnecessarily odd. i ended up wrapping the relation in an object proxy when passing it to the join. the proxy ANDs additional criterion into the primary or secondary join attributes of the relation based on what is supplied

[sqlalchemy] Re: getting data from primary keys

2009-09-15 Thread C.T. Matsumoto
Thanks for the help! T On Tue, Sep 15, 2009 at 12:33 PM, King Simon-NFHD78 simon.k...@motorola.com wrote: -Original Message- From: sqlalchemy@googlegroups.com [mailto:sqlalch...@googlegroups.com] On Behalf Of C.T. Matsumoto Sent: 15 September 2009 07:21 To: