[sqlalchemy] Re: how to handle Date values of the form YYYY-MM-00

2009-02-02 Thread rdmurray

Quoth jason kirtland j...@discorporate.us:
  Now, how do I get SQLAlchemy to pass that dictionary into the MySQLdb
  'connect'?  :)
 
 You can pass it in via the create_engine's connect_args:
 
 http://www.sqlalchemy.org/docs/05/dbengine.html#custom-dbapi-connect-arguments

Thanks.  I should have been able to find that myself :(.

--RDM


--~--~-~--~~~---~--~~
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 
sqlalchemy+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Re: how to handle Date values of the form YYYY-MM-00

2009-02-01 Thread Michael Bayer

Assuming these columns are ultimately CHAR or VARCHAR on the mysql  
side, build your own Date type using TypeDecorator in conjunction with  
the String type.  MySQLdb's date/time functionality only takes effect  
for columns that are of the DATE, TIME or DATETIME columns.


On Feb 1, 2009, at 2:58 PM, rdmur...@bitdance.com wrote:


 I have an existing MySQL database (that I do not control) with schema
 fields defined using the 'Date' type.  The values that occur in these
 fields often have a 'day' of '00', and sometimes a month of '00', and
 sometimes the field's value is -00-00.  The zeros are used to  
 indicate
 don't know (or, sometimes, don't care).

 Since '00' is invalid for the fields in a Python DateTime, it seems  
 as though
 I can't actually use DateTime to manage these values.  My application
 should be able to use them as strings, but how do I arrange to do  
 that?
 The conversion to DateTime is presumably taking place at the DBAPI  
 level.

 --RDM


 


--~--~-~--~~~---~--~~
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 
sqlalchemy+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Re: how to handle Date values of the form YYYY-MM-00

2009-02-01 Thread rdmurray

Quoth Michael Bayer mike...@zzzcomputing.com:
 
 Assuming these columns are ultimately CHAR or VARCHAR on the mysql  
 side, build your own Date type using TypeDecorator in conjunction with  
 the String type.  MySQLdb's date/time functionality only takes effect  
 for columns that are of the DATE, TIME or DATETIME columns.

No, as I said, these are DATE files on the MySQL side.  Which
is exactly the problem.  If they were CHAR, I wouldn't have
a problem :)

 On Feb 1, 2009, at 2:58 PM, rdmur...@bitdance.com wrote:
 
 
  I have an existing MySQL database (that I do not control)
  with schema fields defined using the 'Date' type.  The values
  that occur in these fields often have a 'day' of '00', and
  sometimes a month of '00', and sometimes the field's value is
  -00-00.  The zeros are used to  indicate don't know
  (or, sometimes, don't care).
 
  Since '00' is invalid for the fields in a Python DateTime, it
  seems  as though I can't actually use DateTime to manage
  these values.  My application should be able to use them as
  strings, but how do I arrange to do  that?  The conversion to
  DateTime is presumably taking place at the DBAPI  level.
 
  --RDM


--~--~-~--~~~---~--~~
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 
sqlalchemy+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Re: how to handle Date values of the form YYYY-MM-00

2009-02-01 Thread Michael Bayer

so, MySQLdb itself cant read the columns ?  is there a stack trace or  
anything ? SQLA passes date values straight through to Mysqldb.


On Feb 1, 2009, at 6:31 PM, rdmur...@bitdance.com wrote:


 Quoth Michael Bayer mike...@zzzcomputing.com:

 Assuming these columns are ultimately CHAR or VARCHAR on the mysql
 side, build your own Date type using TypeDecorator in conjunction  
 with
 the String type.  MySQLdb's date/time functionality only takes effect
 for columns that are of the DATE, TIME or DATETIME columns.

 No, as I said, these are DATE files on the MySQL side.  Which
 is exactly the problem.  If they were CHAR, I wouldn't have
 a problem :)

 On Feb 1, 2009, at 2:58 PM, rdmur...@bitdance.com wrote:


 I have an existing MySQL database (that I do not control)
 with schema fields defined using the 'Date' type.  The values
 that occur in these fields often have a 'day' of '00', and
 sometimes a month of '00', and sometimes the field's value is
 -00-00.  The zeros are used to  indicate don't know
 (or, sometimes, don't care).

 Since '00' is invalid for the fields in a Python DateTime, it
 seems  as though I can't actually use DateTime to manage
 these values.  My application should be able to use them as
 strings, but how do I arrange to do  that?  The conversion to
 DateTime is presumably taking place at the DBAPI  level.

 --RDM


 


--~--~-~--~~~---~--~~
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 
sqlalchemy+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Re: how to handle Date values of the form YYYY-MM-00

2009-02-01 Thread jason kirtland

rdmur...@bitdance.com wrote:
 I have an existing MySQL database (that I do not control) with schema
 fields defined using the 'Date' type.  The values that occur in these
 fields often have a 'day' of '00', and sometimes a month of '00', and
 sometimes the field's value is -00-00.  The zeros are used to indicate
 don't know (or, sometimes, don't care).
 
 Since '00' is invalid for the fields in a Python DateTime, it seems as though
 I can't actually use DateTime to manage these values.  My application
 should be able to use them as strings, but how do I arrange to do that?
 The conversion to DateTime is presumably taking place at the DBAPI level.

Check out the MySQLdb docs for the 'conv' type mapping option to 
connect(). I think you should be able to override the default datetime 
with your own convert that falls back to a string or whatever you'd like 
it to do.



--~--~-~--~~~---~--~~
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 
sqlalchemy+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Re: how to handle Date values of the form YYYY-MM-00

2009-02-01 Thread rdmurray

Quoth jason kirtland j...@discorporate.us:
 
 rdmur...@bitdance.com wrote:
  I have an existing MySQL database (that I do not control) with schema
  fields defined using the 'Date' type.  The values that occur in these
  fields often have a 'day' of '00', and sometimes a month of '00', and
  sometimes the field's value is -00-00.  The zeros are used to indicate
  don't know (or, sometimes, don't care).
  
  Since '00' is invalid for the fields in a Python DateTime, it seems as 
  though
  I can't actually use DateTime to manage these values.  My application
  should be able to use them as strings, but how do I arrange to do that?
  The conversion to DateTime is presumably taking place at the DBAPI level.
 
 Check out the MySQLdb docs for the 'conv' type mapping option to 
 connect(). I think you should be able to override the default datetime 
 with your own convert that falls back to a string or whatever you'd like 
 it to do.

That sounds promising, and I doubt I would have found that just by googling,
so thanks!

Now, how do I get SQLAlchemy to pass that dictionary into the MySQLdb
'connect'?  :)

--David



--~--~-~--~~~---~--~~
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 
sqlalchemy+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Re: how to handle Date values of the form YYYY-MM-00

2009-02-01 Thread jason kirtland

rdmur...@bitdance.com wrote:
 Quoth jason kirtland j...@discorporate.us:
 rdmur...@bitdance.com wrote:
 I have an existing MySQL database (that I do not control) with schema
 fields defined using the 'Date' type.  The values that occur in these
 fields often have a 'day' of '00', and sometimes a month of '00', and
 sometimes the field's value is -00-00.  The zeros are used to indicate
 don't know (or, sometimes, don't care).

 Since '00' is invalid for the fields in a Python DateTime, it seems as 
 though
 I can't actually use DateTime to manage these values.  My application
 should be able to use them as strings, but how do I arrange to do that?
 The conversion to DateTime is presumably taking place at the DBAPI level.
 Check out the MySQLdb docs for the 'conv' type mapping option to 
 connect(). I think you should be able to override the default datetime 
 with your own convert that falls back to a string or whatever you'd like 
 it to do.
 
 That sounds promising, and I doubt I would have found that just by googling,
 so thanks!
 
 Now, how do I get SQLAlchemy to pass that dictionary into the MySQLdb
 'connect'?  :)

You can pass it in via the create_engine's connect_args:

http://www.sqlalchemy.org/docs/05/dbengine.html#custom-dbapi-connect-arguments

Cheers,
Jason

--~--~-~--~~~---~--~~
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 
sqlalchemy+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---