|
osdir.com mailing list archive F.A.Q. -since 2001! |
|
|
|
Subject: Re: can't adapt - msg#00084List: python.sqlalchemy.user
by Date: Prev Next Date Index by Thread: Prev Next Thread Index
Ok found it .... it was mod_python fault, which now return StringField
instances in place of str ! Julien Cigar wrote: > Hello, > > Any idea why I get those errors with psycopg2 (not with psycopg1) : > > SQLError: (ProgrammingError) can't adapt 'SELECT habitats.id AS > habitats_id, habitats.habitat AS habitats_habitat \nFROM habitats > \nWHERE habitats.id = %(habitats_id)s ORDER BY habitats.id' > {'habitats_id': '2'} > > What's strange is that I don't have this in the python console when I > issue a query ... > I'm almost sure that it's an Unicode problem (everything is in > Unicode) ... > > I'm connection with: > db_engine = create_engine('...', encoding='utf-8') > > This fails : > form_habitats = self.params.getlist('invasive_habitats') > for hab in form_habitats: > habitat_object = query_habitat.get(hab) > (...) > > If i do like this it works : > form_habitats = self.params.getlist('invasive_habitats') > for hab in form_habitats: > habitat_object = query_habitat.get(hab.decode('utf-8')) > (...) > > Any enlightenment ? > > Thanks, > Julien > ------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
Thread at a glance:
Previous Message by Date:Re: problem with postgres foreign key reflection ?> If using autoload=True when defining your metadata, be sure your FK > constraint names are unique to the schema . PostgreSQL scopes FK > constraint names to the table, but SQLAlchemy loads them from the SQL > standard information_schema, which is designed for schema-scoped > constraint names. While I don't really understand "PostgreSQL scopes FK constraint names to the table", I can say that my patch fixing ticket 71 (when can we see it accepted?) does not load from information_schema and is not schema-scoped: worst than that! the query looks for the foreign keys (and the tables) using the function pg_table_is_visible(c.oid): SELECT conname, pg_catalog.pg_get_constraintdef(oid, true) as condef FROM pg_catalog.pg_constraint r WHERE r.conrelid = ( SELECT c.oid FROM pg_catalog.pg_class c LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace WHERE c.relname = :table_name AND pg_catalog.pg_table_is_visible(c.oid)) AND r.contype = 'f' ORDER BY 1 I can't see any possible drawback of this feature, that makes it possible to autoload tables in one schema referencing tables in another schema that is visible anyhow. If there is a possibility of a mistake this means the table should be specified by the schema (that's a different issue, anyhow), but the fk are bound to their tables by r.conrelid = c.oid sandro *:-) > which is news to me; the query used to reflect foreign keys takes > table name into account, and a unit test which reflects anonymously- > created foreign keys from two different tables works fine (and always > has...). can someone illustrate this problem for me ? -- Sandro Dentella *:-) http://www.tksql.org TkSQL Home page - My GPL work ------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 Next Message by Date:Converting columns definition to formencode schema.Hi, I am trying to convert automatically a list of columns definition to a formencode schema. String,Integer,Float,Numeric,Binary were easy to convert, i.e. just the String(40), not empty, precision, length etc. However, i don't know what to use for: DateTime,Date,Time,Boolean . I am guessing SQLAlchemy does not check the format of these and just lets the engine throw the errors, though unhelpful they may be. Is there anything i can use to decide if a string is indeed at an acceptable DateTime,Date,Time,Boolean format to databases? They don't have to be on the spot, since it is the automatic side of things. For specifics i create custom validators, i.e., i am looking for one, to know if a DateTime is indeed a DateTime format that the database will accept, etc... 10x. -- Regards, Tzahi. -- Tzahi Fadida Blog: http://tzahi.blogsite.org | Home Site: http://tzahi.webhop.info WARNING TO SPAMMERS: see at http://members.lycos.co.uk/my2nis/spamwarning.html ------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 Previous Message by Thread:can't adaptHello, Any idea why I get those errors with psycopg2 (not with psycopg1) : SQLError: (ProgrammingError) can't adapt 'SELECT habitats.id AS habitats_id, habitats.habitat AS habitats_habitat \nFROM habitats \nWHERE habitats.id = %(habitats_id)s ORDER BY habitats.id' {'habitats_id': '2'} What's strange is that I don't have this in the python console when I issue a query ... I'm almost sure that it's an Unicode problem (everything is in Unicode) ... I'm connection with: db_engine = create_engine('...', encoding='utf-8') This fails : form_habitats = self.params.getlist('invasive_habitats') for hab in form_habitats: habitat_object = query_habitat.get(hab) (...) If i do like this it works : form_habitats = self.params.getlist('invasive_habitats') for hab in form_habitats: habitat_object = query_habitat.get(hab.decode('utf-8')) (...) Any enlightenment ? Thanks, Julien ------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 Next Message by Thread:Converting columns definition to formencode schema.Hi, I am trying to convert automatically a list of columns definition to a formencode schema. String,Integer,Float,Numeric,Binary were easy to convert, i.e. just the String(40), not empty, precision, length etc. However, i don't know what to use for: DateTime,Date,Time,Boolean . I am guessing SQLAlchemy does not check the format of these and just lets the engine throw the errors, though unhelpful they may be. Is there anything i can use to decide if a string is indeed at an acceptable DateTime,Date,Time,Boolean format to databases? They don't have to be on the spot, since it is the automatic side of things. For specifics i create custom validators, i.e., i am looking for one, to know if a DateTime is indeed a DateTime format that the database will accept, etc... 10x. -- Regards, Tzahi. -- Tzahi Fadida Blog: http://tzahi.blogsite.org | Home Site: http://tzahi.webhop.info WARNING TO SPAMMERS: see at http://members.lycos.co.uk/my2nis/spamwarning.html ------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
blog comments powered by Disqus
|
|