--
You received this message because you are subscribed to the Google Groups "sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+...@googlegroups.com.
To post to this group, send email to sqlal...@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to a topic in the Google Groups "sqlalchemy" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/sqlalchemy/eThubIMnL4o/unsubscribe.
To unsubscribe from this group and all its topics, send an email to sqlalchemy+...@googlegroups.com.
Can i simply use Unicode Data type for columns where there might be chance of using non ascii data?Thanks for help. But still i have confusion over encoding and decoding procedure which will take place before retrieving and storing the results in DB.In case if i am not using convert_unicode option and data type is String so python process will give str object to sqlalchemy at the time of insert record in DB using ORM. So will alchemy store that object in encoded form?. So at the time of retrieving ORM will give str object for String type column to python and python decode that object with default encoding?
what about CLOB type? Unicode only handles String type. Do i need to use convert_unicode there?
applying convert_unicode to CLOB type does not have any effect. Still I am getting str type object from sqlalchemy for CLOB type column
in case lot of overhead will be there so it is better to use that column label only
On 8/4/15 7:41 AM, Abhishek Sharma wrote:
well it doesn't work anyway because data from a CLOB is not in cx_oracle's world a "String", it's a LOB. The CLOB / NCLOB types for cx_oracle are organized in their own way where only NCLOB actually has unicode handling capability, regardless of the coerce_to_unicode or convert_unicode flags; CLOB does not. So either use NCLOB, or build out your own convert unicode, here is a demo:in case lot of overhead will be there so it is better to use that column label only
is this followings two instructions compulsory while defining new type?
m.drop_all(e)
m.create_all(e)
this instructions are not feasible , because DB team already defined schema and normal user can not drop and create table.
Hi Team,I have created customized data type using TypeDecorator approach.
from sqlalchemy import TypeDecorator, CLOBclass ForceUnicodeClob(TypeDecorator):
impl = CLOBdef process_bind_param(self, value, dialect):
if isinstance(value, str):
value = value.decode('utf-8', 'ignore')
return valuedef process_result_value(self, value, dialect):
if value is not None:
value = "PREFIX" + value.decode('utf-8', 'ignore')
return value
After this in my table definition I declared the type of one of column as ForceUnicodeClob.dlr_dclmr = Table('dlr_dclmr', metadata,
Column('dclmr_ds', ForceUnicodeClob(), primary_key=False))
After this I am executing the query on this table with session.query(Model) , but when I am accessing result.dclmr_ds i am not getting response prepended with "PREFIX".
Hi Team,
With asynchronous request my model object Unicode type column not returning Unicode object but if I do same action using synchronous I am getting Unicode object
Hi Team,
With asynchronous request my model object Unicode type column not returning Unicode object but if I do same action using synchronous I am getting Unicode object
SQLAlchemy has no asynchrnous API itself so this has to do with the asynchronous framework you're using and how you are integrating it with SQLAlchemy.
Hi Team,
We are not calling all or first method on got query object. We are just passing query object to set method of python and we are getting Unicode Error "ASCII CODEC Can not decode" this means I am not getting Unicode Object from SQLAlchemy side.
Column('dlrprod_name_pri', Unicode(length=100), primary_key=False),Do I need to call all or first method on query object to get Unicode object rather than str object.
I am using session.query(Model).filter(conditions) but still getting UnicodeErrors
On 8/12/15 11:07 AM, Abhishek Sharma wrote:
I am using session.query(Model).filter(conditions) but still getting UnicodeErrors
unfortunately this all goes back to the test script I shared with you; that script works. What's different in your application that distinguishes the system of querying from that of the test script?
| prod_survey = Table('prod_survey', metadata, | |||||||||||||||||||||||
| Column( | |||||||||||||||||||||||
| u'survey_prod_id', | |||||||||||||||||||||||
| NUMERIC( | |||||||||||||||||||||||
| precision=18, | |||||||||||||||||||||||
| scale=0, | |||||||||||||||||||||||
| asdecimal=False), | |||||||||||||||||||||||
| primary_key=True, | |||||||||||||||||||||||
| nullable=False), | |||||||||||||||||||||||
| Column( | |||||||||||||||||||||||
| u'survey_id', | |||||||||||||||||||||||
| NUMERIC( | |||||||||||||||||||||||
| precision=9, | |||||||||||||||||||||||
| scale=0, | |||||||||||||||||||||||
| asdecimal=False), | |||||||||||||||||||||||
primary_key=False),
Now When I am assigning Products from Product table to survey table I am getting ascii encoding can not encode character. It means python is getting Unicode object but trying to encode before sending to DB param. Please suggest |
Hi Mike,
I am attaching the Code and Model Info in which I am facing issue.Please let me know if you need more info from my side
well this is still not the level of test script that I can do anything with, it's only a fragment of the actual program, so at least if you can turn on echo=True it will show the SQL statement and the parameters being emitted, that will at least illustrate what column or element of the SQL string itself has non-ascii characters in it that match the exception.
Hi Team,
We are executing select query using self.session.query(Model).filter(filter_conditions).first()
Then we are storing the about query result in result variable.
Then we are trying to update one of model attribute like
result.description=value
Even though we have not added that object in session to update the DB and there is no commit but sqlalchemy emitting update query on DB.
...
Hi Team,
We are executing select query using self.session.query(Model).filter(filter_conditions).first()Then we are storing the about query result in result variable.
Then we are trying to update one of model attribute like
result.description=value
Even though we have not added that object in session to update the DB and there is no commit but sqlalchemy emitting update query on DB.