[sqlalchemy] Re: CASE , CAST, COALESCE

2006-12-13 Thread Jose Soares

Great!

jo


Michael Bayer ha scritto:
 we have case():

 select(case([(table.c.x==5, 5), (table.c.y==7, 12)], else_=7))

 and cast():

   select([cast(table.c.x, Numeric)])

 which are in the generated documentation for sql.py.

 for coalesce() you can call that as func.coalesce() for now.


 
   


--~--~-~--~~~---~--~~
 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] PickleType and MySQL: want mediumblob instead of blob

2006-12-13 Thread [EMAIL PROTECTED]

Hi,

Using SA 0.3.2 with Python (TurboGears) and MySQL I see that my
PickleType column is stored as a blob in the MySQL table.

Can I change the following table definition so that my 'info' column is
stored as a mediumblob in MySQL instead of a blob?

data_set_table = Table('dataset', metadata,
Column('info', PickleType(), default={})
)

Thanks,
toffe


--~--~-~--~~~---~--~~
 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: Again MySQL/unicode - roundtrip failed

2006-12-13 Thread Michael Bayer

in fact its almost definitely a bug in mysqldb - mysqldb should be
detecting unicode instances at on the bind parameter side and
encoding based on that (otherwise doing nothing), and decoding into
unicode instances at the result set level.  if it did that, then it
would not conflict with the Unicode type on SQLAlchemy's side.  here is
the source to the SA unicode type:

class Unicode(TypeDecorator):
impl = String
def convert_bind_param(self, value, dialect):
 if value is not None and isinstance(value, unicode):
  return value.encode(dialect.encoding)
 else:
  return value
def convert_result_value(self, value, dialect):
 if value is not None and not isinstance(value, unicode):
 return value.decode(dialect.encoding)
 else:
 return value

as evidence of this, the above Unicode type works completely fine with
pysqlite, which also accepts unicode bind params and returns all string
values as unicodes.


--~--~-~--~~~---~--~~
 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: Again MySQL/unicode - roundtrip failed

2006-12-13 Thread Shannon -jj Behrens

My memory is that MySQLdb recently changed a bunch of stuff and that
it was a simple logic bug.  Here's the bug I filed:

http://sourceforge.net/tracker/index.php?func=detailaid=1592353group_id=22307atid=374932

On 12/13/06, Michael Bayer [EMAIL PROTECTED] wrote:

 in fact its almost definitely a bug in mysqldb - mysqldb should be
 detecting unicode instances at on the bind parameter side and
 encoding based on that (otherwise doing nothing), and decoding into
 unicode instances at the result set level.  if it did that, then it
 would not conflict with the Unicode type on SQLAlchemy's side.  here is
 the source to the SA unicode type:

 class Unicode(TypeDecorator):
 impl = String
 def convert_bind_param(self, value, dialect):
  if value is not None and isinstance(value, unicode):
   return value.encode(dialect.encoding)
  else:
   return value
 def convert_result_value(self, value, dialect):
  if value is not None and not isinstance(value, unicode):
  return value.decode(dialect.encoding)
  else:
  return value

 as evidence of this, the above Unicode type works completely fine with
 pysqlite, which also accepts unicode bind params and returns all string
 values as unicodes.


 



-- 
http://jjinux.blogspot.com/

--~--~-~--~~~---~--~~
 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
-~--~~~~--~~--~--~---