Re: [sqlalchemy] Determining sqa type from dialect type
On Aug 10, 2012, at 5:19 AM, Warwick Prince wrote: Hi All If I have a Column() object, is there a way of determining the sqlalchemy type from the dialect specific type? e.g. I have a Postgres TIMESTAMP column, and I want to be able to map that back the a sqa DateTime type. column.type._type_affinity I have moved on now with this information, but I've hit a snag which appears to be bug in either core or possibly (more likely) mysqlconnector. When I ask for column.type._type_affinity on a LONGBLOB column in a MySQL database, it returns _Binary which is not correct (Should be LargeBinary). Please confirm if this is a core issue, or should I go hunting in the connector code? Cheers Warwick -- 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.
Re: [sqlalchemy] Determining sqa type from dialect type
On Aug 11, 2012, at 5:50 AM, Warwick Prince wrote: On Aug 10, 2012, at 5:19 AM, Warwick Prince wrote: Hi All If I have a Column() object, is there a way of determining the sqlalchemy type from the dialect specific type? e.g. I have a Postgres TIMESTAMP column, and I want to be able to map that back the a sqa DateTime type. column.type._type_affinity I have moved on now with this information, but I've hit a snag which appears to be bug in either core or possibly (more likely) mysqlconnector. When I ask for column.type._type_affinity on a LONGBLOB column in a MySQL database, it returns _Binary which is not correct (Should be LargeBinary). Please confirm if this is a core issue, or should I go hunting in the connector code? _type_affinity is semi-public right now so is possibly not exactly tailored towards what you're doing right now.Your best bet is to keep using it, but also use a lookup table (dictionary: {LONGBLOB:_LargeBinary} ) to make corrections in cases like these. A public feature version of _type_affinity would be able to have more general use contract but I don't want to tweak _type_affinity directly right now as I'd need to spend time determining the impact of that. -- 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] Determining sqa type from dialect type
Hi All If I have a Column() object, is there a way of determining the sqlalchemy type from the dialect specific type? e.g. I have a Postgres TIMESTAMP column, and I want to be able to map that back the a sqa DateTime type. Why? If I want to automatically clone tables from one database to another (of different types) I can't simply clone the table metadata and use it to table.create in the destination engine. In my case source is MySQL destination is Postgres and it fails (correctly) saying that it does not know what a datetime type is. (Because it's using the MySQL dialect DATETIME not sqa DateTime as the basis of the column. Effectively, I want to reverse engineer the creation of the column. Cheers Warwick Warwick Prince Managing Director mobile: +61 411 026 992 skype: warwickprince phone: +61 7 3102 3730 fax: +61 7 3319 6734 web: www.mushroomsys.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 sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
Re: [sqlalchemy] Determining sqa type from dialect type
On Aug 10, 2012, at 5:19 AM, Warwick Prince wrote: Hi All If I have a Column() object, is there a way of determining the sqlalchemy type from the dialect specific type? e.g. I have a Postgres TIMESTAMP column, and I want to be able to map that back the a sqa DateTime type. Why? column.type._type_affinity -- 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.
Re: [sqlalchemy] Determining sqa type from dialect type
Hi Michel Thanks! I knew it was in there somewhere! :-) Cheers Warwick Hi All If I have a Column() object, is there a way of determining the sqlalchemy type from the dialect specific type? e.g. I have a Postgres TIMESTAMP column, and I want to be able to map that back the a sqa DateTime type. Why? column.type._type_affinity -- 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. -- 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.