[sqlalchemy] Do you have a way to track easily the source of « SAWarning: Unicode type received non-unicode bind param value. » ?
Hi, do you have a way to track easily the source of « SAWarning: Unicode type received non-unicode bind param value. » ? I know I have a bad assignation, I've put a string in unicode field but I don't found where. What tip do you use to found it ? Regards, Stephane -- 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] Do you have a way to track easily the source of « SAWarning: Unicode type received non-unicode bind param value. » ?
On 23/05/2011 08:47, Stéphane Klein wrote: I know I have a bad assignation, I've put a string in unicode field but I don't found where. What tip do you use to found it ? I think you can do this by setting the warning filter to error early in your application: import warnings warnings.filterwarnings('error') More info here: http://docs.python.org/library/warnings.html#warnings.filterwarnings cheers, Chris -- Simplistix - Content Management, Batch Processing Python Consulting - http://www.simplistix.co.uk -- 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: Do you have a way to track easily the source of « SAWarning: Unicode type received non-unicode bind param value. » ?
Great news ! With : import warnings warnings.filterwarnings('error') and SQLAlchemy 0.7.0 I can see unicode value issue in error message. Thanks for your help, Stéphane -- 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: Do you have a way to track easily the source of « SAWarning: Unicode type received non-unicode bind param value. » ?
use python -W error your_script.py or PYTHONWARNINGS=error your_script On 23 Maj, 10:17, Stéphane Klein steph...@harobed.org wrote: On 23 mai, 10:14, Chris Withers ch...@simplistix.co.uk wrote: I think you can do this by setting the warning filter to error early in your application: import warnings warnings.filterwarnings('error') Same issue here, I see the error but I don't know where is the bad assignation. -- 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: Do you have a way to track easily the source of « SAWarning: Unicode type received non-unicode bind param value. » ?
looks like my previous message diseappeared somehow:( PYTHONWARNINGS=error::RuntimeWarning::0,error::UnicodeWarning::0 your_script.py On 23 Maj, 10:17, Stéphane Klein steph...@harobed.org wrote: On 23 mai, 10:14, Chris Withers ch...@simplistix.co.uk wrote: I think you can do this by setting the warning filter to error early in your application: import warnings warnings.filterwarnings('error') Same issue here, I see the error but I don't know where is the bad assignation. -- 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: creating tables and mappers multiple times in the same python script
On May 22, 2011, at 5:43 AM, Faheem Mitha wrote: [This message has also been posted.] On Fri, 20 May 2011 09:44:36 -0400, Michael Bayer mike...@zzzcomputing.com wrote: OK so not just schema names, table structure as well. So yeah so you're using the same classes among entirely different databases essentially, so yeah just like our tests do, just tear down before remapping for a new DB and you're done. Hi Michael, Ok, thanks for the suggestion. Can you point me to a place in your unit tests where this tear down happens? this is in test/lib/fixtures.py Also, can you reply regarding the 'tometadata' thing? Not super important, but I'm just curious about what it does, exactly. Thanks. I don't really understand the questions you've asked there. table.tometadata() makes a copy of table, where table is a sqlalchemy.schema.Table object, linked to a new MetaData, and returns to you the newly generated sqlalchemy.schema.Table object. If you need a list of Table objects to go through this procedure then yes a loop is how you'd do 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] memory usage of the session in a loop
Hello, When a loop is constructed out of a query, eg : for a in query: print a where query is a query that returns objects. and you look at the identity_map of the session, inside the loop, you see that it contains all objects -- 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] memory usage of the session in a loop
Hello, When a loop is constructed out of a query, eg : for a in query: print a where query is a query that returns objects. and you look at the identity_map of the session, inside the loop, you see that it contains all objects the query will return. I would appear to me that only one object at a time is needed during the loop, and so the identity map should only contain 1 instance. Is my understanding wrong, or am I missing something ? Thank you and best regards, Erik -- 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] memory usage of the session in a loop
please see Query.yield_per() in the documentation. On May 23, 2011, at 3:48 PM, erikj wrote: Hello, When a loop is constructed out of a query, eg : for a in query: print a where query is a query that returns objects. and you look at the identity_map of the session, inside the loop, you see that it contains all objects the query will return. I would appear to me that only one object at a time is needed during the loop, and so the identity map should only contain 1 instance. Is my understanding wrong, or am I missing something ? Thank you and best regards, Erik -- 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.
[sqlalchemy] Re: memory usage of the session in a loop
very nice, works like a charm ! Thanks a lot Michael On May 23, 10:06 pm, Michael Bayer mike...@zzzcomputing.com wrote: please see Query.yield_per() in the documentation. On May 23, 2011, at 3:48 PM, erikj wrote: Hello, When a loop is constructed out of a query, eg : for a in query: print a where query is a query that returns objects. and you look at the identity_map of the session, inside the loop, you see that it contains all objects the query will return. I would appear to me that only one object at a time is needed during the loop, and so the identity map should only contain 1 instance. Is my understanding wrong, or am I missing something ? Thank you and best regards, Erik -- 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 athttp://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.
[sqlalchemy] Declarative: Joined Inheritance + Two Tables To One Object
I have the following: class Person(Base): __tablename__ = 'pessoa' id = Column(id_person), Integer, primary_key = True) name = Column(String) class Teacher(Person): __tablename__ = 'teacher' id = Column(id_teacher, Integer, ForeignKey(Person.id), primary_key=True) info = Column(String) class Salary(Base): __tablename__ = 'salary' id = Column(String) value = Column(Numeric) That's ok, but I wanted to merge the Salary and Teacher objects following the guide: http://www.sqlalchemy.org/docs/06/orm/mapper_config.html#mapping-a-class-against-multiple-tables Am I forced to map the Teacher and Salary in the non-declarative mode to achieve this? It's nice to keep things declarative, because it automatically create the __init__ method with the columns as parameters. I have another classes that have relationships to those classes (and they are declarative too), and things get nasty when I mix declarative with the standard way. -- 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: Declarative: Joined Inheritance + Two Tables To One Object
D'oh, I figured myself, It was very easy. I just followed the guide again and it worked. One question though. Let's use the guide example for this: Let's say that AddressUser inherits(joined inheritance) from another class, and that class have a id with the same name (user_id), I get a warning like this: Implicitly combining column address.user_id with column superclass.user_id under attribute 'user_id'. This usage will be prohibited in 0.7. Please configure one or more attributes for these same-named columns explicitly. All ids are indeed, the same id so it seems ok for me. Why is it being prohibited? Issued with advanced cases, or just to avoid hard-to-debug errors? 2011/5/23 Israel Ben Guilherme Fonseca israel@gmail.com I have the following: class Person(Base): __tablename__ = 'pessoa' id = Column(id_person), Integer, primary_key = True) name = Column(String) class Teacher(Person): __tablename__ = 'teacher' id = Column(id_teacher, Integer, ForeignKey(Person.id), primary_key=True) info = Column(String) class Salary(Base): __tablename__ = 'salary' id = Column(String) value = Column(Numeric) That's ok, but I wanted to merge the Salary and Teacher objects following the guide: http://www.sqlalchemy.org/docs/06/orm/mapper_config.html#mapping-a-class-against-multiple-tables Am I forced to map the Teacher and Salary in the non-declarative mode to achieve this? It's nice to keep things declarative, because it automatically create the __init__ method with the columns as parameters. I have another classes that have relationships to those classes (and they are declarative too), and things get nasty when I mix declarative with the standard way. -- 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.