[sqlalchemy] convert_unicode option when using postgre and psycopg2

2011-10-28 Thread Manav Goel
Hi I am using sqlalchemy with postgresql and psycopg2. I want to write unicode compatible web application. I noticed that when I pass string data to sqlalchemy string column, its get converted to unicode after commit. So does setting convert_unicode option True has any meaning in this

[sqlalchemy] Do not check for truth value of instance in _get_from_identity

2011-10-28 Thread Daniel Nouri
The _get_from_identity method of sqlalchemy.orm.query.Query starts like this: @classmethod def _get_from_identity(cls, session, key, passive): instance = session.identity_map.get(key) if instance: # ... This is problematic for me since my model class is a

Re: [sqlalchemy] convert_unicode option when using postgre and psycopg2

2011-10-28 Thread Michael Bayer
convert_unicode these days is by default conditional - if the DBAPI accepts Python unicode objects directly, and/or can be coerced to return unicode objects directly, SQLAlchemy doesn't do any encoding. This is the case with psycopg2 which both accepts Python unicode objects as bound

Re: [sqlalchemy] Do not check for truth value of instance in _get_from_identity

2011-10-28 Thread Michael Bayer
On Oct 28, 2011, at 9:26 AM, Daniel Nouri wrote: The _get_from_identity method of sqlalchemy.orm.query.Query starts like this: @classmethod def _get_from_identity(cls, session, key, passive): instance = session.identity_map.get(key) if instance: # ... UGH

[sqlalchemy] Python to pl/python

2011-10-28 Thread rdunklau
Hello guys. As a proof of concept, I implemented a hacky python to pl/python converter using python3 function annotations. You can see it there if it's of interest to any of you: https://github.com/rdunklau/pytoplpython This led me to some questions. SQLAlchemy automatically manages tables and

[sqlalchemy] Re: get raw sql for create type and tables

2011-10-28 Thread lestat
I need print this sql code if these ENUM types and tables and indexes exist. On 28 окт, 18:28, lestat lestatc...@googlemail.com wrote: How I can get raw sql for this table? class Test(db.Model):     __tablename__ = 'test'     id = db.Column(db.Integer, primary_key=True)     birthday =

[sqlalchemy] Re: get raw sql for create type and tables

2011-10-28 Thread lestat
If I do this: from sqlalchemy import * from StringIO import StringIO buf = StringIO() pg_engine = create_engine('sqlite://', strategy='mock', executor=lambda s,p=';': buf.write(s.__str__() + p)) buf.truncate(0) tables = [x[1] for x in sorted(db.metadata.tables.items(), key=lambda x: x[0])] for

[sqlalchemy] ConcreteBase (0.7.3) only supporting 1 level of inheritance ?

2011-10-28 Thread JPLaverdure
Hello, I started playing with Concrete Table Inheritance this morning and tried to implement a portion of my schema: class Mixin(object): __table_args__ = {'schema':'test'} id = Column(Integer, primary_key=True) class Node(ConcreteBase, Base, Mixin): __tablename__ = 'node'

[sqlalchemy] recursion loop

2011-10-28 Thread Burak Arslan
hi, any ideas on what could be the cause of the following backtrace here? https://gist.github.com/1322636#comments. this is probably something i'll need to fix in rpclib code, but I don't see what causes this. sqlalchemy version is latest trunk from today. the backtrace is one line off because

[sqlalchemy] Pool size question

2011-10-28 Thread Mike Orr
I have a few Pylons applications that share a SQL access log routine. Yesterday I migrated it from MySQL to PostgreSQL, and I'm getting a bunch of errors like this: connection = self.contextual_connect(close_with_result=True) Module sqlalchemy.engine.base:1229 in contextual_connect return

[sqlalchemy] Re: Pool size question

2011-10-28 Thread Mike Orr
On Fri, Oct 28, 2011 at 9:53 AM, Mike Orr sluggos...@gmail.com wrote: I have a few Pylons applications that share a SQL access log routine. Yesterday I migrated it from MySQL to PostgreSQL, and I'm getting a bunch of errors like this:  connection =

Re: [sqlalchemy] Re: get raw sql for create type and tables

2011-10-28 Thread Michael Bayer
I can make a ticket for this since the Enum type is using the deprecated event system and PG's event here doesn't have access to the checkfirst flag. Ticket #2311. For now you'd have to not use the native enum type with PG, or patch out that checkfirst=True inside of postgresql/base.py,

Re: [sqlalchemy] ConcreteBase (0.7.3) only supporting 1 level of inheritance ?

2011-10-28 Thread Michael Bayer
this is why I hate adding new features, b.c. now i have to support them, though concrete with declarative really needed a push.The abstract concrete bases have probably not yet been tested with multiple-level inheritance. Hard to say where things are going wrong without running a test and

Re: [sqlalchemy] Pool size question

2011-10-28 Thread Michael Bayer
On Oct 28, 2011, at 12:53 PM, Mike Orr wrote: I have a few Pylons applications that share a SQL access log routine. Yesterday I migrated it from MySQL to PostgreSQL, and I'm getting a bunch of errors like this: connection = self.contextual_connect(close_with_result=True) Module

Re: [sqlalchemy] recursion loop

2011-10-28 Thread Michael Bayer
Looks like something related to deserializing without mappers set up, or deserializing into an environment where the class structure and/or mappers are not configured the same way. This is usually not the way that manifests itself, though. The key would be the change that started causing the

Re: [sqlalchemy] ConcreteBase (0.7.3) only supporting 1 level of inheritance ?

2011-10-28 Thread JPLaverdure
Hello Michael, Sorry to be the thorn in your side.. I attached a test case as requested.. Ticket 2312. Also, it seems this is incompatible with history_meta based versioning. (Which probably has to do with the use of the __declare_last__() function. Thank you -- You received this message

Re: [sqlalchemy] recursion loop

2011-10-28 Thread Burak Arslan
On 28.10.2011 21:07, Michael Bayer wrote: Looks like something related to deserializing without mappers set up, or deserializing into an environment where the class structure and/or mappers are not configured the same way. This is usually not the way that manifests itself, though. The key

Re: [sqlalchemy] recursion loop

2011-10-28 Thread Michael Bayer
On Oct 28, 2011, at 3:16 PM, Burak Arslan wrote: the link I provided has both the client and server implementations to reproduce the issue, maybe you didn't scroll up? Did not scroll up, no.So looking at the sample code here, it's entirely a mystery to me how this is even supposed to

[sqlalchemy] Enforce range on Column(Numeric)

2011-10-28 Thread Michael Hipp
Could someone point me to a doc page that explains how to enforce a range limit on a Numeric type. I have some monetary values that I want to force to always be = Decimal('0.00'). Thanks, Michael -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To

Re: [sqlalchemy] ConcreteBase (0.7.3) only supporting 1 level of inheritance ?

2011-10-28 Thread Michael Bayer
On Oct 28, 2011, at 2:28 PM, JPLaverdure wrote: Hello Michael, Sorry to be the thorn in your side.. I attached a test case as requested.. Ticket 2312. thanks for the ticket and this is fixed in radadaccc1bb5 . Also, it seems this is incompatible with history_meta based versioning.

Re: [sqlalchemy] Enforce range on Column(Numeric)

2011-10-28 Thread Michael Bayer
use a TypeDecorator like http://www.sqlalchemy.org/docs/core/types.html#rounding-numerics and change the rounding part to raise an error. On Oct 28, 2011, at 6:27 PM, Michael Hipp wrote: Could someone point me to a doc page that explains how to enforce a range limit on a Numeric type. I

Re: [sqlalchemy] recursion loop

2011-10-28 Thread Burak Arslan
On 29.10.2011 00:10, Michael Bayer wrote: On Oct 28, 2011, at 3:16 PM, Burak Arslan wrote: the link I provided has both the client and server implementations to reproduce the issue, maybe you didn't scroll up? Did not scroll up, no.So looking at the sample code here, it's entirely a

Re: [sqlalchemy] recursion loop

2011-10-28 Thread Michael Bayer
On Oct 28, 2011, at 7:09 PM, Burak Arslan wrote: Here's how to reproduce: from sqlalchemy import * from sqlalchemy.ext.declarative import declarative_base Base= declarative_base() class A(Base): __tablename__ = a id = Column(Integer, primary_key=True) class B(A):