[sqlalchemy] Re: use_ansi oracle sysdate vs. current_date

2010-04-02 Thread Kent
Along the same lines, is there something we can do about nvl() (oracle) versus coalesce() (ansi)? They aren't exactly the same, unfortunately (nvl takes exactly 2 arguments, no more), so maybe there is nothing 'official' you can do, but can you help me work it out for my project? I assume it is

Re: [sqlalchemy] PyODBCConnector dbapi question

2010-04-02 Thread Gaetan de Menten
On Tue, Mar 30, 2010 at 19:32, Michael Bayer mike...@zzzcomputing.com wrote: Bo Shi wrote: pep 249 specifies list of tuples for fetchmany() and fetchall() Hrm, pep-249 seems to only specify sequence and sequence of sequences for the fetch*() functions, specifying list of tuples only as one

Re: [sqlalchemy] Re: use_ansi oracle sysdate vs. current_date

2010-04-02 Thread Michael Bayer
Kent wrote: Along the same lines, is there something we can do about nvl() (oracle) versus coalesce() (ansi)? They aren't exactly the same, unfortunately (nvl takes exactly 2 arguments, no more), so maybe there is nothing 'official' you can do, but can you help me work it out for my project?

Re: [sqlalchemy] Re: use_ansi oracle sysdate vs. current_date

2010-04-02 Thread Kent Bower
Thanks very much. On 4/2/2010 5:41 PM, Michael Bayer wrote: Kent wrote: Along the same lines, is there something we can do about nvl() (oracle) versus coalesce() (ansi)? They aren't exactly the same, unfortunately (nvl takes exactly 2 arguments, no more), so maybe there is nothing

Re: [sqlalchemy] Re: use_ansi oracle sysdate vs. current_date

2010-04-02 Thread Kent Bower
As an aside, more recent Oracles support ansi coalesce, so it is probably more appropriate to only use nvl() for older, non-ansi Oracle versions, but if this is only for illustration then that is not a big deal (unless you don't want people writing to you saying coalesce does support more than

Re: [sqlalchemy] Re: use_ansi oracle sysdate vs. current_date

2010-04-02 Thread Michael Bayer
Kent Bower wrote: As an aside, more recent Oracles support ansi coalesce, so it is probably more appropriate to only use nvl() for older, non-ansi Oracle versions, but if this is only for illustration then that is not a big deal (unless you don't want people writing to you saying coalesce

Re: [sqlalchemy] Re: use_ansi oracle sysdate vs. current_date

2010-04-02 Thread Ian Kelly
On Fri, Apr 2, 2010 at 3:41 PM, Michael Bayer mike...@zzzcomputing.comwrote: Kent wrote: Along the same lines, is there something we can do about nvl() (oracle) versus coalesce() (ansi)? They aren't exactly the same, unfortunately (nvl takes exactly 2 arguments, no more), so maybe

[sqlalchemy] Re: use_ansi oracle sysdate vs. current_date

2010-04-02 Thread Kent
Just to be inconsistent, with one argument, databases handle this differently: postgres: # select coalesce(0); coalesce -- 0 (1 row) Oracle 10g: select coalesce(0) from dual * ERROR at line 1: ORA-00938: not enough arguments for function On Apr 2, 7:08 pm, Ian Kelly

[sqlalchemy] Re: Sharding with _BindParamClause

2010-04-02 Thread George V. Reilly
Michael Bayer wrote: check out r0ddd638f1d90 in mercurial.  I've added the function from the example below, plus support for in_op(), to the attribute_shard example. The old ClauseVisitor method is removed and replaced with this more robust method. Very nice! Thanks, Michael. /George --

[sqlalchemy] Re: Sharding with _BindParamClause

2010-04-02 Thread George V. Reilly
On Apr 2, 4:43 pm, George V. Reilly george.v.rei...@gmail.com wrote: Michael Bayer wrote: check out r0ddd638f1d90 in mercurial.  I've added the function from the example below, plus support for in_op(), to the attribute_shard example. The old ClauseVisitor method is removed and replaced

Re: [sqlalchemy] Re: use_ansi oracle sysdate vs. current_date

2010-04-02 Thread Kent Bower
By the way, Unless a ClauseList is subscriptable in 0.6, I had problems the way it was. Here is what I did: @compiles(coalesce, 'oracle') def compile(element, compiler, **kw): sql = nvl(%s) clauses = map(compiler.process, element.clauses) for i in xrange(len(clauses) - 2):

[sqlalchemy] Re: with_polymorphic

2010-04-02 Thread Kent
After doing more reading, this only relates to multiple class inheritance, which is useful anytime you want two or more classes to relate to the same record return from the database, is that an accurate summary? I'm trying to get of real-life feel for which situations would benefit from multiple

Re: [sqlalchemy] array_agg() in ORM entities (0.5.8)?

2010-04-02 Thread David Gardner
I was able to come up with a work-around, since this is part of a report, I was able to format the dates as strings the way I was planning to do in python anyways: qry=session.query(Task, func.cat(func.to_char(TaskHistory.updated,'MM/DD/YY HH:MI am'))) This works well for my needs (cat()

[sqlalchemy] Can not access the __table__ attribute in string-based primaryjoin parameter

2010-04-02 Thread Jack
People can use string-based primaryjoin parameter to define the sqlalchemy.orm.relation instance if people use declarative base class. But the __table__ attribute is not available. Look at this example. Chassis and Blade are sub-class of System. The sysid property shares the same name in parent

Re: [sqlalchemy] Re: Sharding with _BindParamClause

2010-04-02 Thread Michael Bayer
George V. Reilly wrote: I really don't like the isinstance(other_side, sqlalchemy.sql.expression._BindParamClause)) in the middle of _check_side. Is there a cleaner way to do this? I found that a combination of * the above _check_side and two-sided visit_binary * doing a better job of

Re: [sqlalchemy] Before I send

2010-04-02 Thread Michael Bayer
Michael Mileusnich wrote: Hello, I know there is documentation on this but I am still fuzzy on certain practices when using the session. In my application I have a function that returns a new non scoped session. In one method (method a) I get object o from this session. I call another

Re: [sqlalchemy] Re: with_polymorphic

2010-04-02 Thread Michael Bayer
Kent wrote: After doing more reading, this only relates to multiple class inheritance, which is useful anytime you want two or more classes to relate to the same record return from the database, is that an accurate summary? I wouldn't say its accurate. SQLA doesn't support any pattern of

Re: [sqlalchemy] Can not access the __table__ attribute in string-based primaryjoin parameter

2010-04-02 Thread Michael Bayer
Jack wrote: People can use string-based primaryjoin parameter to define the sqlalchemy.orm.relation instance if people use declarative base class. But the __table__ attribute is not available. Look at this example. its a limited subset of behaviors which are allowed within the evaluated

Re: [sqlalchemy] Re: Sharding with _BindParamClause

2010-04-02 Thread Michael Bayer
Michael Bayer wrote: George V. Reilly wrote: I really don't like the isinstance(other_side, sqlalchemy.sql.expression._BindParamClause)) in the middle of _check_side. Is there a cleaner way to do this? I found that a combination of * the above _check_side and two-sided visit_binary *

Re: [sqlalchemy] PyODBCConnector dbapi question

2010-04-02 Thread Michael Bayer
Michael Bayer wrote: Bo Shi wrote: pep 249 specifies list of tuples for fetchmany() and fetchall() Hrm, pep-249 seems to only specify sequence and sequence of sequences for the fetch*() functions, specifying list of tuples only as one possible example. Perhaps the C implementation of

Re: [sqlalchemy] PyODBCConnector dbapi question

2010-04-02 Thread Bo Shi
Awesome! Thanks! We work with large amounts of time series data so we have high hopes for the c extension. Bo On Fri, Apr 2, 2010 at 2:38 PM, Michael Bayer mike...@zzzcomputing.com wrote: Michael Bayer wrote: Bo Shi wrote: pep 249 specifies list of tuples for fetchmany() and fetchall()

Re: [sqlalchemy] PyODBCConnector dbapi question

2010-04-02 Thread Bo Shi
Hrm, some different errors pop up. I'll move the dialog to the ticket in question. http://www.sqlalchemy.org/trac/ticket/1757 On Fri, Apr 2, 2010 at 2:40 PM, Bo Shi bs1...@gmail.com wrote: Awesome!  Thanks! We work with large amounts of time series data so we have high hopes for the c

[sqlalchemy] Re: use_ansi oracle sysdate vs. current_date

2010-04-02 Thread Kent
Any chance you plan to make func.now consider oracle and use_ansi=False (and return sysdate)? On Feb 3, 4:44 pm, Michael Bayer mike...@zzzcomputing.com wrote: Kent wrote: Any chance SQLAlchemy has a mechanism to switch to or fromsysdatevs. current_datebased on the database dialect (and

Re: [sqlalchemy] Re: use_ansi oracle sysdate vs. current_date

2010-04-02 Thread Michael Bayer
Kent wrote: Any chance you plan to make func.now consider oracle and use_ansi=False (and return sysdate)? the use_ansi flag should be removed as far as public API since we can detect server version now. we can also make now() return sysdate() unconditionally on oracle, you should give us a