[sqlalchemy] Re: similiraty search
On Jan 30, 4:16 am, Michael Bayer mike...@zzzcomputing.com wrote: You're in luck since this is a fun relational problem - yes I'm in luck, as everyone on this list to have you around ! thank you so much, I'm quite new to relational problems, and I was way over my head with this one. Now I almost feel as I understand the solution, thanks to your detailed explanation. Surely your answer should finds its way to the cookbook, as maybe this will be of interest to others. Best NiL -- 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] Trailing L after my Primary Key
Hi, I'm reflecting some tables out of MySQL for a User object and when I call: user.ID I get a value like this: 10L instead of: 10 If I wrap it up like this: int(user.ID) I get: 10 It seems that the reflection thinks my int column is a long. Why is that happening and how can I fix it? Abandon reflection? Thanks, Jon -- 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] Trailing L after my Primary Key
On Jan 30, 2011, at 8:55 PM, ObjectEvolution wrote: Hi, I'm reflecting some tables out of MySQL for a User object and when I call: user.ID I get a value like this: 10L instead of: 10 If I wrap it up like this: int(user.ID) I get: 10 It seems that the reflection thinks my int column is a long. Why is that happening and how can I fix it? Abandon reflection? MySQL-python returns ints as Python longs. They are cross compatible. SQLA's reflection is not involved. from sqlalchemy import * e = create_engine('mysql://scott:tiger@localhost/test') print repr(e.scalar(select([1]))) print repr(e.scalar(select([cast(1, Integer)]))) raw_mysqldb_connection = e.connect().connection cursor = raw_mysqldb_connection.cursor() cursor.execute(select 1) print cursor.fetchall() output: 1L 1L ((1L,),) -- 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: Trailing L after my Primary Key
Thanks Michael. So then it looks like my options are to: 1. Convert the longs. 2. Declare my columns instead of using reflection so I get the right types. On Jan 30, 7:18 pm, Michael Bayer mike...@zzzcomputing.com wrote: On Jan 30, 2011, at 8:55 PM, ObjectEvolution wrote: Hi, I'm reflecting some tables out of MySQL for a User object and when I call: user.ID I get a value like this: 10L instead of: 10 If I wrap it up like this: int(user.ID) I get: 10 It seems that the reflection thinks my int column is a long. Why is that happening and how can I fix it? Abandon reflection? MySQL-python returns ints as Python longs. They are cross compatible. SQLA's reflection is not involved. from sqlalchemy import * e = create_engine('mysql://scott:tiger@localhost/test') print repr(e.scalar(select([1]))) print repr(e.scalar(select([cast(1, Integer)]))) raw_mysqldb_connection = e.connect().connection cursor = raw_mysqldb_connection.cursor() cursor.execute(select 1) print cursor.fetchall() output: 1L 1L ((1L,),) -- 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: Trailing L after my Primary Key
Actually, answered that myself as soon as I pressed 'send'. ;-) On Jan 30, 7:23 pm, ObjectEvolution objectevolut...@gmail.com wrote: Thanks Michael. So then it looks like my options are to: 1. Convert the longs. 2. Declare my columns instead of using reflection so I get the right types. On Jan 30, 7:18 pm, Michael Bayer mike...@zzzcomputing.com wrote: On Jan 30, 2011, at 8:55 PM, ObjectEvolution wrote: Hi, I'm reflecting some tables out of MySQL for a User object and when I call: user.ID I get a value like this: 10L instead of: 10 If I wrap it up like this: int(user.ID) I get: 10 It seems that the reflection thinks my int column is a long. Why is that happening and how can I fix it? Abandon reflection? MySQL-python returns ints as Python longs. They are cross compatible. SQLA's reflection is not involved. from sqlalchemy import * e = create_engine('mysql://scott:tiger@localhost/test') print repr(e.scalar(select([1]))) print repr(e.scalar(select([cast(1, Integer)]))) raw_mysqldb_connection = e.connect().connection cursor = raw_mysqldb_connection.cursor() cursor.execute(select 1) print cursor.fetchall() output: 1L 1L ((1L,),) -- 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] Re: Trailing L after my Primary Key
On Jan 30, 2011, at 10:23 PM, ObjectEvolution wrote: Thanks Michael. So then it looks like my options are to: 1. Convert the longs. 2. Declare my columns instead of using reflection so I get the right types. If your concern is they print funny, you should use str() for formatting. Python ints and longs are otherwise fully cross-compatible. As I said, not using reflection makes no difference here, unless your plan is to use a custom TypeDecorator against Integer to force the int() call as rows are fetched. Otherwise, reflection knows your column type is INTEGER.The reason for the longs is that your MySQL-python library is returns ints as longs, and SQLA's Integer type does not interfere with this. On Jan 30, 7:18 pm, Michael Bayer mike...@zzzcomputing.com wrote: On Jan 30, 2011, at 8:55 PM, ObjectEvolution wrote: Hi, I'm reflecting some tables out of MySQL for a User object and when I call: user.ID I get a value like this: 10L instead of: 10 If I wrap it up like this: int(user.ID) I get: 10 It seems that the reflection thinks my int column is a long. Why is that happening and how can I fix it? Abandon reflection? MySQL-python returns ints as Python longs. They are cross compatible. SQLA's reflection is not involved. from sqlalchemy import * e = create_engine('mysql://scott:tiger@localhost/test') print repr(e.scalar(select([1]))) print repr(e.scalar(select([cast(1, Integer)]))) raw_mysqldb_connection = e.connect().connection cursor = raw_mysqldb_connection.cursor() cursor.execute(select 1) print cursor.fetchall() output: 1L 1L ((1L,),) -- 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.