[sqlalchemy] Joins: Returning multiple instances, and a potential bug

2010-10-31 Thread Michael Elsdörfer
I'm sorry if this is an obvious question, but there seem to be a couple ways to do joins, and I seem unable to find an example explaining how to achieve my particular result. I need to join two tables, and I want the mapper objects of both tables returned. Essentially, I want

[sqlalchemy] mapper for outerjoin: getting None objects

2010-10-31 Thread Alessandro Dentella
Hi, I have a join between 2 tables (User/Adresses, complete code below). I create a mapper as the join of the 2 classes as: m = orm.mapper(Join, User.__table__.outerjoin(Address.__table__) , properties = { 'j_id' : [Address.__table__.c.user_id,

Re: [sqlalchemy] NamedTuple error in multiple join?

2010-10-31 Thread Michael Bayer
On Oct 30, 2010, at 5:59 PM, James Hartley wrote: The following Python code: for t in session.query(func.max(Cron.timestamp)).\ join((Snapshot, Cron.id == Snapshot.cron_id), (Platform, Platform.id == Snapshot.platform_id)).\ filter(Platform.id ==

Re: [sqlalchemy] Joins: Returning multiple instances, and a potential bug

2010-10-31 Thread Michael Bayer
On Oct 31, 2010, at 3:43 AM, Michael Elsdörfer wrote: session.query(m1, m2) but of course, that doesn't do an actual join, and I need to use filter() instead of an onclause. While in this particular case I don't really care, I would imagine that there probably are scenarios where one

Re: [sqlalchemy] mapper for outerjoin: getting None objects

2010-10-31 Thread Michael Bayer
On Oct 31, 2010, at 9:05 AM, Alessandro Dentella wrote: Hi, I have a join between 2 tables (User/Adresses, complete code below). I create a mapper as the join of the 2 classes as: m = orm.mapper(Join, User.__table__.outerjoin(Address.__table__) , properties = {

[sqlalchemy] Re: mapper for outerjoin: getting None objects

2010-10-31 Thread sandro dentella
Thanks as usual for your valuable and prompt response sandro *:-) -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalch...@googlegroups.com. To unsubscribe from this group, send email to

[sqlalchemy] How to separate models into own modules?

2010-10-31 Thread Daniel Meier
Hi list I have tried the examples in the ORM tutorial and I'm wondering how I can separate different models into own modules. Let's say I have a BankAccount model and a BankCustomer model. My idea would be to create two modules, bankaccount.py and bankcustomer.py, and a database handler that

[sqlalchemy] DataError: invalid input value for enum

2010-10-31 Thread Michael Hipp
I have a model that looks something like this: TRANS_CODES = ( 'SellCar', 'BuyCar', 'BuyFee', 'SellFee', 'Gas/Fuel', 'Detail', 'Wash/Vac', 'Trans/Hauling', 'Service/Repair', 'DraftFee', 'Misc', 'Cash', 'CheckPaid', 'CheckRcvd', 'FloorPlan', 'Draft') class Trans(Base): __tablename__

[sqlalchemy] Re: How to separate models into own modules?

2010-10-31 Thread jgs9000
Hi Daniel I do it like this: http://pastie.org/1263024 not 100% what's up with yours, but my way works Jon On Nov 1, 6:08 am, Daniel Meier herr.schn...@gmail.com wrote: Hi list I have tried the examples in the ORM tutorial and I'm wondering how I can separate different models into

[sqlalchemy] Best usage while using session

2010-10-31 Thread Guguscat
Hello, I am using SQLAlchemy in a Pylons project and I like it. However I am questioning about the best way to insert data into a database. I have a User class mapping my user table which has a Column 'username' which has a unique constraint. So I have a form to add a new user when I submit

Re: [sqlalchemy] How to separate models into own modules?

2010-10-31 Thread Col Wilson
In my opinion it's best to keep the 'application model' all in one place as it shows you at a glance the relationships within the app. On Sun, Oct 31, 2010 at 7:08 PM, Daniel Meier herr.schn...@gmail.com wrote: Hi list I have tried the examples in the ORM tutorial and I'm wondering how I can

Re: [sqlalchemy] DataError: invalid input value for enum

2010-10-31 Thread Michael Bayer
check that the ENUM type which was generated, or its CHECK constraint, includes Cash. With the Enum type, you can't add new values to the list without also changing the ENUM type or CHECK constraint. On Oct 31, 2010, at 7:25 PM, Michael Hipp wrote: I have a model that looks something