[sqlalchemy] ClauseList with join?

2008-10-11 Thread sandro dentella

Hi,

  I started using the .join() method on query and that' s really
powerful, with reset_joinpoint and the list of attributes setting the
path of relations. Now I'd like to being able to write join clause in
advance with respect to the moment I have the the query available , in
he same way I can write ClauseList in advance. Is there any way?

Thanks
sandro
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Re: select count group_by where ?

2008-10-11 Thread Lukasz Szybalski

On Sat, Oct 11, 2008 at 10:24 PM, Michael Bayer
[EMAIL PROTECTED] wrote:

 We should really fix the MSSQL dialect to not be throwing a
 SystemError when a SQL statement is not successfully interpreted.


I guess syntax error would be more appropriate.


 I can't see anything wrong with the statement otherwise unless MSSQL
 has a problem with the same column being in GROUP BY as well as an
 aggregate.  I'd get it to work at the SQL prompt first.


The list [ ] in a group_by function has caused the error.

Lucas

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Re: Suppressing SADeprecationWarning: 'length' is deprecated for Numeric. Use 'scale'. for multi-version implementations of SQLAlchemy

2008-10-11 Thread Julian Yap

On Oct 11, 5:32 pm, Michael Bayer [EMAIL PROTECTED] wrote:
 On Oct 11, 2008, at 8:40 PM, Julian Yap wrote:
  Hi All,

  According to this change set 
  --http://www.sqlalchemy.org/trac/changeset/5054
  The 'length' argument to all Numeric types has been renamed to
  'scale'. 'length' is deprecated and is still accepted with a warning.

  On my workstation, I have SQLAlchemy 0.5.0rc1 whereas on some servers
  I have 0.4.7p1 (due to Python 2.3).

  Running a script on my workstation spits out the deprecation warnings.

  What would be the best way to re-write my script so it's backwards
  compatible to 0.4.x and doesn't spit out the deprecation warnings in
  0.5.x?

  Here's an example line:
  model.py:54: SADeprecationWarning: 'length' is deprecated for
  Numeric.  Use 'scale'.
   schema.Column('balance', types.Numeric(precision=20, length=6),
  nullable=False, default=0.00),

  I'm thinking perhaps a try block at the start of my model.py script
  which tests for the SQLAlchemy version?

 Two ways to do this.  One is to make a wrapper function around Numeric  
 which does the right thing based on SQLAlchemy version, i.e.

 def Numeric(**kwargs):
     if SQLALCHEMY_4:
          kwargs['scale'] = kwargs.pop('length', None)
     return types.Numeric(**kwargs)

 The other is just to use the warnings filter to suppress the warning,  
 as described inhttp://www.python.org/doc/2.4.2/lib/warning-
 filter.html .

The wrapper function sounds the best.  That way the bulk of my code
will run the latest version of SQLAlchemy.

How would you implement it?

Here's a code example:
--- Begin model.py ---
from sqlalchemy import schema, types
from sqlalchemy import orm

metadata = schema.MetaData()
customers_table = schema.Table('customers', metadata,
schema.Column('id', types.Integer, nullable=False,
primary_key=True),
schema.Column('balance', types.Numeric(precision=20, length=6),
nullable=False, default=0.00),
)

class Customers(object):
pass

orm.mapper(Customers, customers_table)
--- End model.py ---

I imagine I can do this the following:

Add this line:
from sqlalchemy.types import Numberic

Modify this line to read:
schema.Column('balance', Numeric(precision=20, scale=6),
nullable=False, default=0.00),

Ideally, it would be cleaner if I just added some code at the top and
modified this line to read:
schema.Column('balance', types.Numeric(precision=20, scale=6),
nullable=False, default=0.00),

Thanks,
Julian

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---