[sqlalchemy] Re: Problems Inserting into Oracle using Bind Variables from Turbo Gears Controller

2007-05-03 Thread shday

I'm getting this error even though I have convert_unicode = True and
the proper NLS_LANG setting:

SQLError: (NotSupportedError) Variable_TypeByValue(): unhandled data
type unicode 'DELETE FROM model_acc_protocol WHERE
model_acc_protocol.model_id = :model_id AND
model_acc_protocol.acc_protocol_id = :acc_protocol_id AND
model_acc_protocol.color = :color' {'model_id': 60, 'color': u'RED',
'acc_protocol_id': u'2001-99'}

I know my convert_unicode = True is doing something because it solved
others problems before. Somehow it isn't working here. One thing that
is different here is that the values u'RED' and u'2001-99' were pulled
from the database during the same flush(). In the select statement
just before this one these value were bound as 'RED' and '2001-99'
instead of unicode.

Any ideas?

Steve


On Apr 25, 1:08 pm, Michael Bayer [EMAIL PROTECTED] wrote:
 On Apr 25, 2007, at 12:26 PM, kap_ravi wrote:



  Apparently there is some problem with theUNICODEdatathat sqlAlchemy
  sends to oracle from the turbo gears framework. But I have tried the
  same from the python command line with named parameters and its works
  without any issues.

 feeding inunicodestrings requires that they be encoded into  
 bytestrings first.  this can be accomplished by either the usage of  
 theUnicodetypeon your Column definitions, or by sending the flag  
 convert_unicode=True to create_engine().  the default encoding for  
 this flag is utf-8 which can be configured by the 'encoding' flag  
 sent to create_engine().

 additionally, when using Oracle, you have to ensure that the  
 environment variable NLS_LANG is set appropriately, such as AMERICAN-
 AMERICA.UTF8.


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Re: Problems Inserting into Oracle using Bind Variables from Turbo Gears Controller

2007-05-03 Thread Michael Bayer


On May 3, 2007, at 11:25 AM, shday wrote:


 I'm getting this error even though I have convert_unicode = True and
 the proper NLS_LANG setting:

 SQLError: (NotSupportedError) Variable_TypeByValue(): unhandled data
 type unicode 'DELETE FROM model_acc_protocol WHERE
 model_acc_protocol.model_id = :model_id AND
 model_acc_protocol.acc_protocol_id = :acc_protocol_id AND
 model_acc_protocol.color = :color' {'model_id': 60, 'color': u'RED',
 'acc_protocol_id': u'2001-99'}

 I know my convert_unicode = True is doing something because it solved
 others problems before. Somehow it isn't working here. One thing that
 is different here is that the values u'RED' and u'2001-99' were pulled
 from the database during the same flush(). In the select statement
 just before this one these value were bound as 'RED' and '2001-99'
 instead of unicode.


those two values should not be u'' strings.  therefore it would  
appear that those bindparams are untyped.  if you are using bindparam 
() directly, add type=Unicode to it.  similarly for whatever other  
constructs youre making which arent derived from a Column, make sure  
types are sent in as appropriate.   ( a construct derived from a  
Column would look like mytable.c.somecolumn == u'foo', in that case  
the Unicode type should be generated automatically).

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Re: Problems Inserting into Oracle using Bind Variables from Turbo Gears Controller

2007-05-03 Thread shday

The problem seems to be related to a backref I had. I found a way
without using backref and now things work.

With this I get a unicode error:
acc_mapper =
mapper(ACCProtocolSpecies,acc_protocol_species_table,properties={'models':relation(Model,secondary=model_acc_protocol_table,lazy=False,backref='acc_protocols'),
 
'study_requests':relation(StudyRequest,secondary=model_acc_protocol_table,lazy=False)})
With this I don't:
acc_mapper =
mapper(ACCProtocolSpecies,acc_protocol_species_table,properties={'models':relation(Model,secondary=model_acc_protocol_table,lazy=False),
 
'study_requests':relation(StudyRequest,secondary=model_acc_protocol_table,lazy=False)})

Here is the related tg controller code:

@expose()
def delete(self,model_id):
model = dbmodel.session.query(dbmodel.Model).get([model_id])
acc_protocol_id = model.acc_protocols[0].acc_protocol_id
species = model.acc_protocols[0].species

record =
dbmodel.session.query(dbmodel.ModelACCProtocol).get([model_id,
acc_protocol_id, species])
dbmodel.session.delete(record)
dbmodel.session.delete(model)
dbmodel.session.flush()

return Deleted







On May 3, 12:04 pm, Michael Bayer [EMAIL PROTECTED] wrote:
 On May 3, 2007, at 11:25 AM, shday wrote:







  I'm getting this error even though I have convert_unicode = True and
  the proper NLS_LANG setting:

  SQLError: (NotSupportedError) Variable_TypeByValue(): unhandled data
  type unicode 'DELETE FROM model_acc_protocol WHERE
  model_acc_protocol.model_id = :model_id AND
  model_acc_protocol.acc_protocol_id = :acc_protocol_id AND
  model_acc_protocol.color = :color' {'model_id': 60, 'color': u'RED',
  'acc_protocol_id': u'2001-99'}

  I know my convert_unicode = True is doing something because it solved
  others problems before. Somehow it isn't working here. One thing that
  is different here is that the values u'RED' and u'2001-99' were pulled
  from the database during the same flush(). In the select statement
  just before this one these value were bound as 'RED' and '2001-99'
  instead of unicode.

 those two values should not be u'' strings.  therefore it would  
 appear that those bindparams are untyped.  if you are using bindparam
 () directly, add type=Unicode to it.  similarly for whatever other  
 constructs youre making which arent derived from a Column, make sure  
 types are sent in as appropriate.   ( a construct derived from a  
 Column would look like mytable.c.somecolumn == u'foo', in that case  
 the Unicode type should be generated automatically).- Hide quoted text -

 - Show quoted text -


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Re: Problems Inserting into Oracle using Bind Variables from Turbo Gears Controller

2007-05-03 Thread Michael Bayer


On May 3, 2007, at 2:41 PM, shday wrote:


 The problem seems to be related to a backref I had. I found a way
 without using backref and now things work.

 With this I get a unicode error:
 acc_mapper =
 mapper(ACCProtocolSpecies,acc_protocol_species_table,properties= 
 {'models':relation 
 (Model,secondary=model_acc_protocol_table,lazy=False,backref='acc_prot 
 ocols'),

 'study_requests':relation 
 (StudyRequest,secondary=model_acc_protocol_table,lazy=False)})
 With this I don't:
 acc_mapper =
 mapper(ACCProtocolSpecies,acc_protocol_species_table,properties= 
 {'models':relation 
 (Model,secondary=model_acc_protocol_table,lazy=False),

 'study_requests':relation 
 (StudyRequest,secondary=model_acc_protocol_table,lazy=False)})


Ok well thats a bug in SA.   what is the specific join condition to  
the model_acc_protocol_table / primary keys in the related tables ?   
'color' and 'acc_protocol_id' are foreign key columns in the  
association table (and are part of how the relationship joins ?)  a  
stack trace here would tell me the bug is where i think it is (my  
guess is, dependency.py line 383).

I also notice you have the same table used as a secondary table in  
two different relationships which also might create confusion but not  
related to unicode.



--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---