[sqlalchemy] ORM join question

2013-11-19 Thread askel
Hello everybody, I have a question I couldn't find answer on my own so I'll greatly appreciate if someone could give me an answer. Considering simple model https://gist.github.com/momyc/7554839, why would query like the following work:

Re: [sqlalchemy] ORM join question

2013-11-19 Thread askel
Thank you Michael for quick response. On Tuesday, November 19, 2013 8:36:55 PM UTC-4, Michael Bayer wrote: On Nov 19, 2013, at 7:11 PM, askel dumm...@mail.ru javascript: wrote: Hello everybody, I have a question I couldn't find answer on my own so I'll greatly appreciate if someone could

Re: [sqlalchemy] Re: Extending sqlalchemy.schema.Table

2013-08-08 Thread askel
Askel... What I'd like to accomplish is to add few more attributes and methods to Table (or maybe override insert/update/delete/select) to do post processing of the Result/Row proxies and return them in different formats such as json, yaml, xml, etc... so, while you suggestion is really

[sqlalchemy] Boolean Mapper property from exists subquery

2013-08-08 Thread askel
Hello everyone, I've been using SQLAlchemy for a while and it's been a pleasure. But sometimes I feel I can get a little more from it or do something more properly. For instance, imagine two tables with one-to-one relationship bosth sharing the same primary key and second table containing

[sqlalchemy] Re: Extending sqlalchemy.schema.Table

2013-08-01 Thread askel
There is column_reflect event triggered for each column during table reflection. Most likely your extra functionality depends on some columns so I'd look at something like: from sqlalchemy.event import listens_for columns_to_reflect = set(('id', 'name', 'real_name',

Re: [sqlalchemy] Extending sqlalchemy.schema.Table

2013-08-01 Thread askel
No offence but it feels like direct route to the hell. Monkeypatching is acknowledged to be really bad practise in general with few exemptions. On Thursday, August 1, 2013 9:47:45 AM UTC-4, Simon King wrote: It's a horrible hack, but did you know that you can change the class of an instance

[sqlalchemy] Dynamic relationship in queries

2013-07-28 Thread askel
Hello everybody, I've been tearing my hairs out trying to figure out how to achieve the following. Base = declarative_base() class Group(Base): g_id = Column(Integer, primary_key=True) events = relationship('Event', backref='group', lazy='dynamic') class

[sqlalchemy] Re: Dynamic relationship in queries

2013-07-28 Thread askel
What I have ended up with is the following: class Group(Base): events = relationship('Event', lazy=True) session.query(Group).join(Group.events).options(contains_eager(Group.events).filter(Event.e_date=='2013-01-01') The above gives me what I want and does not look crazy. It might be using

Re: [sqlalchemy] Dynamic relationship in queries

2013-07-28 Thread askel
AM, askel dumm...@mail.ru javascript: wrote: What I have ended up with is the following: class Group(Base): events = relationship('Event', lazy=True) session.query(Group).join(Group.events).options(contains_eager(Group.events).filter(Event.e_date=='2013-01-01') The above gives me what

[sqlalchemy] Re: sqlalchemy and informixdb

2009-10-20 Thread askel
Looks like I'm experiencing similar problems with InformixDB 2.5 and SQLAlchemy 0.5.6. Whenever parameters are sent for execution it looks like integers are used instead of placeholders like ? or :1. Flollowing are some examples: 2009-10-20 11:12:46,235 INFO

[sqlalchemy] Re: sqlalchemy and informixdb

2009-10-20 Thread askel
Michael, I'm sorry for calling you Mike. There is admin Mike that was giving me hard time all this morning and I have been writing to him alot recently. Cheers Alexander On Oct 20, 12:18 pm, askel dummy...@mail.ru wrote: Hi Mike, create_engine(..., paramstyle='qmark') has fixed

[sqlalchemy] Using select clause for column default

2008-05-22 Thread askel
Hello everybody, I'm having hard time figuring out how or whether it is possible at all to use select statement that can access record to be inserted as column's default value. groups = Table('groups', meta, Column('id', Integer, primary_key=True), Column('prefix', String(32),

[sqlalchemy] Re: Using select clause for column default

2008-05-22 Thread askel
Thank you Michael On May 22, 12:37 pm, Michael Bayer [EMAIL PROTECTED] wrote: On May 22, 2008, at 12:23 PM, askel wrote: Hello everybody, I'm having hard time figuring out how or whether it is possible at all to use select statement that can access record to be inserted

[sqlalchemy] Re: Using select clause for column default

2008-05-22 Thread askel
PROTECTED] wrote: On May 22, 2008, at 12:23 PM, askel wrote: Hello everybody, I'm having hard time figuring out how or whether it is possible at all to use select statement that can access record to be inserted as column's default value. groups = Table('groups', meta, Column('id

[sqlalchemy] Delayed foreign key resolving

2008-03-31 Thread askel
Hello everybody, I'm wondering if there is a standard way of doing something like the following: masters = Table('masters', meta, Column('id', Integer, primary_key=True), Column('name', String, unique, nullable=False) ) details = Table('details', meta, Column('id', Integer,

[sqlalchemy] Portable exceptions in SA

2007-09-12 Thread askel
Hello everybody, I was wondering why neither DBAPI nor SA define standard exceptions like Duplicate key error. It seems to be no portable way to catch this situations and give user more sensible error messages than just We are failed to insert a new record. And using exception information to

[sqlalchemy] Re: Portable exceptions in SA

2007-09-12 Thread askel
trouble than its worth, as far as it being built-in, default behavior. The number of exception concepts that are truly portable is relatively low (like duplicate key), so any such functionality I'd say would have to remain as an electable. On Sep 12, 2007, at 11:30 AM, askel wrote: Hello

[sqlalchemy] Re: Portable exceptions in SA

2007-09-12 Thread askel
. On Sep 12, 2007, at 11:30 AM, askel wrote: Hello everybody, I was wondering why neither DBAPI nor SA define standard exceptions like Duplicate key error. It seems to be no portable way to catch this situations and give user more sensible error messages than just We are failed

[sqlalchemy] Adding few deferred properties from select()

2007-05-02 Thread askel
Hello everyone! I'm trying to implement deferred property loading using select(): summaries = select( [ func.max(transactions.c.processed_at).label('last_used'), func.count(transactions.c.id).label('times_used'), ], from_obj=[transactions], ).alias('summaries') account_mapper =

[sqlalchemy] Re: Adding few deferred properties from select()

2007-05-02 Thread askel
Michael, Thank you for answering. The following is what I tried in order to follow your advise: account_summaries = select( [ transactions.c.account_id, func.max(transactions.c.processed_at).label('last_used'), func.count(transactions.c.id).label('times_used'), ],

[sqlalchemy] Re: Adding few deferred properties from select()

2007-05-02 Thread askel
Michael, transaction.account_id is not a primary key of transactions table. I added fields I use for grouping to primary_key. Then I had to add foreign_key argument to 'summary' relation() call. And finally it all worked as expected. However, I noticed that it doesn't actually matter which

[sqlalchemy] Re: Adding few deferred properties from select()

2007-05-02 Thread askel
On May 2, 8:28 pm, Michael Bayer [EMAIL PROTECTED] wrote: take a look at your SQL output with echo and make sure the queries make sense. that it works with arbitrary columns as pk/fk could just be due to particular data youre working with, but you definitely want to pick a proper candidate

[sqlalchemy] Re: Column default that is aware of whole record to be inserted

2007-03-01 Thread askel
('value', Numeric(12,2), nullable=False,default=prev_balance), ) On Mar 1, 4:30 pm, Michael Bayer [EMAIL PROTECTED] wrote: use a python function as your column default ? http://www.sqlalchemy.org/docs/metadata.myt#metadata_defaults_oninsert On Feb 28, 6:00 pm, askel [EMAIL PROTECTED] wrote

[sqlalchemy] Re: Column default that is aware of whole record to be inserted

2007-03-01 Thread askel
Michael, On Mar 1, 8:04 pm, Michael Bayer [EMAIL PROTECTED] wrote: people ask for this function occasionally, what i dont like about it is that it would greatly complicate things just to produce functionality that isnt really needed. It wasn't my intention to ask anybody to implement such a

[sqlalchemy] Informix SA backend

2007-01-29 Thread askel
Hello everybody, I have done some initial implementation of Informix as one of SA backend. It is currently using InformixDB 2.3. I'd like to share what was already implemented with SA community. Database schema reflection needs pretty much work. Also, I don't have access to anything but IDS