cx_Oracle-5.0.2

This is what is causing the error:
===============================================================================
SELECT CAST('test unicode returns' AS NVARCHAR2(60)) AS anon_1 FROM
DUAL
            *
ERROR at line 1:
ORA-12704: character set mismatch
===============================================================================

I believe all we need is inside
def _check_unicode_returns(self, connection):
...
...
        try:
            unicode_for_unicode = check_unicode(sqltypes.Unicode(60))
        except exc.DBAPIError, e:
            util.warn("Exception while detecting unicode returns: %s"
% e)
            unicode_for_unicode = False


change the except to include cx_Oracle.DatabaseError instead of only
exc.DBAPIError

But, my preference would be that it just not check if the version of
oracle is lower than 9, because it just saves the check from the
database for something we know will fail, can it just set
unicode_for_unicode = False
for Oracle lower than 9?




It is dying on what should be:
"SELECT CAST('test unicode returns' AS VARCHAR(60)) AS anon_1 FROM
DUAL"

But running that alone works fine.  I'm wondering if the SELECT
statement *itself* might



On May 17, 6:53 pm, Michael Bayer <mike...@zzzcomputing.com> wrote:
> here's a patch.   I can confirm the error with the server_version_info.   But 
> not sure what the actual cause of the ORA-12704 is.  what cx_oracle version 
> is it ?
>
>
>
> On May 17, 2010, at 5:16 PM, Kent wrote:
>
> > I think it is using the other select:
> > ================================================================================
> > Connected to:
> > Oracle8i Enterprise Edition Release 8.1.7.4.0 - Production
> > With the Partitioning option
> > JServer Release 8.1.7.4.0 - Production
>
> > Session altered.
>
> > SQL> SELECT CAST('test unicode returns' AS VARCHAR(60 CHAR)) AS anon_1
> > FROM DUAL
> >  2  ;
> > SELECT CAST('test unicode returns' AS VARCHAR(60 CHAR)) AS anon_1 FROM
> > DUAL
> >                                                 *
> > ERROR at line 1:
> > ORA-00907: missing right parenthesis
> > ================================================================================
>
> > It seems to be detecting the version correctly:
>
> > -----------------------
> > from sqlalchemy import *
>
> > engine = create_engine('oracle://user:p...@ipaddress:1521/live?
> > use_ansi=False',echo=True)
> > try:
> >    engine.connect()
> > except:
> >    # because we know its not working
> >    print 'exception caught'
> > print engine.dialect.server_version_info
>
> > (tg2env)[ra...@eld appserver]$ python ora8.py
> > 2010-05-17 14:08:39,339 INFO sqlalchemy.engine.base.Engine.0x...db50
> > SELECT USER FROM DUAL
> > 2010-05-17 14:08:39,344 INFO sqlalchemy.engine.base.Engine.0x...db50
> > {}
> > exception caught
> > (8, 1, 7, 4, 0)
> > -----------------------
>
> > Setting 'engine.dialect.supports_char_length = False' causes
> > "ORA-12704: character set mismatch"
>
> > =========================================================================
> > try:
> >    engine.dialect.supports_char_length = False
> >    engine.connect()
> > except Exception as e:
> >    # because we know its not working
> >    print str(e)
> > print engine.dialect.server_version_info
> > =========================================================================
>
> > 2010-05-17 14:13:55,687 INFO sqlalchemy.engine.base.Engine.0x...fb50
> > SELECT USER FROM DUAL
> > 2010-05-17 14:13:55,690 INFO sqlalchemy.engine.base.Engine.0x...fb50
> > {}
> > ORA-12704: character set mismatch
>
> > (8, 1, 7, 4, 0)
>
> > On May 17, 4:58 pm, Kent <k...@retailarchitects.com> wrote:
> >> Sorry, posted too quickly, I'll get the rest of the results you asked
> >> about...
>
> >> On May 17, 4:56 pm, Kent <k...@retailarchitects.com> wrote:
>
> >>> Connected to:
> >>> Oracle8i Enterprise Edition Release 8.1.7.4.0 - Production
> >>> With the Partitioning option
> >>> JServer Release 8.1.7.4.0 - Production
>
> >>> Session altered.
>
> >>> SQL> SELECT CAST('test unicode returns' AS VARCHAR(60)) AS anon_1 FROM
> >>> DUAL
> >>>   2  ;
>
> >>> ANON_1
> >>> ------------------------------------------------------------
> >>> test unicode returns
>
> >>> SQL>
>
> >>> On May 17, 4:47 pm, Michael Bayer <mike...@zzzcomputing.com> wrote:
>
> >>>> So there's a call upon first connect which is along the lines of:
>
> >>>> SELECT CAST('test unicode returns' AS VARCHAR(60 CHAR)) AS anon_1 FROM 
> >>>> DUAL
>
> >>>> when you're on oracle 8, it should be checking server version, and 
> >>>> coming out as:
>
> >>>> SELECT CAST('test unicode returns' AS VARCHAR(60)) AS anon_1 FROM DUAL
>
> >>>> so step one is make sure the second statement works on Oracle 8.   step 
> >>>> two, we'd have to make sure the server version detection is working.   
> >>>> you can force this particular case like:
>
> >>>> engine = create_engine('oracle://...')
> >>>> engine.dialect.supports_char_length = False
>
> >>>> besides that, I'd like to see:
>
> >>>> engine = create_engine('oracle://...')
> >>>> try:
> >>>>     engine.connect()
> >>>> except:
> >>>>     # because we know its not working
> >>>>     pass
> >>>> print engine.dialect.server_version_info
>
> >>>> this particular interaction doesn't go through regular SQLAlchemy 
> >>>> logging.  If you really needed to see it occur you'd have to watch your 
> >>>> oracle query logs.
>
> >>>> On May 17, 2010, at 3:37 PM, Kent wrote:
>
> >>>>> After migrating to 0.6, we've got an apparently well running
> >>>>> application for postgres and Oracle 9 or above.  However, as soon as
> >>>>> we connect to an Oracle 8 database, *everything* we attempt ends with
> >>>>> this: oracle error: "ORA-00907: missing right parenthesis"
>
> >>>>> Here is an example trying to run a session query.......:
>
> >>>>>>>> DBSession.query(SystemParameter).all()
> >>>>> 12:35:01,294 INFO  [sqlalchemy.engine.base.Engine.0x...5650] SELECT
> >>>>> USER FROM DUAL
> >>>>> 12:35:01,294 INFO  [sqlalchemy.engine.base.Engine.0x...5650] {}
> >>>>> Traceback (most recent call last):
> >>>>>  File "<console>", line 1, in <module>
> >>>>>  File "/home/rarch/tg2env/lib/python2.6/site-packages/
> >>>>> SQLAlchemy-0.6.0-py2.6-linux-x86_64.egg/sqlalchemy/orm/query.py", line
> >>>>> 1343, in all
> >>>>>    return list(self)
> >>>>>  File "/home/rarch/trunk/src/appserver/pylotengine/__init__.py", line
> >>>>> 73, in __iter__
> >>>>>    return Query.__iter__(self)
> >>>>>  File "/home/rarch/tg2env/lib/python2.6/site-packages/
> >>>>> SQLAlchemy-0.6.0-py2.6-linux-x86_64.egg/sqlalchemy/orm/query.py", line
> >>>>> 1451, in __iter__
> >>>>>    return self._execute_and_instances(context)
> >>>>>  File "/home/rarch/tg2env/lib/python2.6/site-packages/
> >>>>> SQLAlchemy-0.6.0-py2.6-linux-x86_64.egg/sqlalchemy/orm/query.py", line
> >>>>> 1456, in _execute_and_instances
> >>>>>    mapper=self._mapper_zero_or_none())
> >>>>>  File "/home/rarch/tg2env/lib/python2.6/site-packages/
> >>>>> SQLAlchemy-0.6.0-py2.6-linux-x86_64.egg/sqlalchemy/orm/session.py",
> >>>>> line 736, in execute
> >>>>>    return self._connection_for_bind(engine,
> >>>>> close_with_result=True).execute(
> >>>>>  File "/home/rarch/tg2env/lib/python2.6/site-packages/
> >>>>> SQLAlchemy-0.6.0-py2.6-linux-x86_64.egg/sqlalchemy/orm/session.py",
> >>>>> line 701, in _connection_for_bind
> >>>>>    return self.transaction._connection_for_bind(engine)
> >>>>>  File "/home/rarch/tg2env/lib/python2.6/site-packages/
> >>>>> SQLAlchemy-0.6.0-py2.6-linux-x86_64.egg/sqlalchemy/orm/session.py",
> >>>>> line 319, in _connection_for_bind
> >>>>>    conn = bind.contextual_connect()
> >>>>>  File "/home/rarch/tg2env/lib/python2.6/site-packages/
> >>>>> SQLAlchemy-0.6.0-py2.6-linux-x86_64.egg/sqlalchemy/engine/base.py",
> >>>>> line 1592, in contextual_connect
> >>>>>    return self.Connection(self, self.pool.connect(),
> >>>>> close_with_result=close_with_result, **kwargs)
> >>>>>  File "/home/rarch/tg2env/lib/python2.6/site-packages/
> >>>>> SQLAlchemy-0.6.0-py2.6-linux-x86_64.egg/sqlalchemy/pool.py", line 154,
> >>>>> in connect
> >>>>>    return _ConnectionFairy(self).checkout()
> >>>>>  File "/home/rarch/tg2env/lib/python2.6/site-packages/
> >>>>> SQLAlchemy-0.6.0-py2.6-linux-x86_64.egg/sqlalchemy/pool.py", line 318,
> >>>>> in __init__
> >>>>>    rec = self._connection_record = pool.get()
> >>>>>  File "/home/rarch/tg2env/lib/python2.6/site-packages/
> >>>>> SQLAlchemy-0.6.0-py2.6-linux-x86_64.egg/sqlalchemy/pool.py", line 173,
> >>>>> in get
> >>>>>    return self.do_get()
> >>>>>  File "/home/rarch/tg2env/lib/python2.6/site-packages/
> >>>>> SQLAlchemy-0.6.0-py2.6-linux-x86_64.egg/sqlalchemy/pool.py", line 665,
> >>>>> in do_get
> >>>>>    con = self.create_connection()
> >>>>>  File "/home/rarch/tg2env/lib/python2.6/site-packages/
> >>>>> SQLAlchemy-0.6.0-py2.6-linux-x86_64.egg/sqlalchemy/pool.py", line 134,
> >>>>> in create_connection
> >>>>>    return _ConnectionRecord(self)
> >>>>>  File "/home/rarch/tg2env/lib/python2.6/site-packages/
> >>>>> SQLAlchemy-0.6.0-py2.6-linux-x86_64.egg/sqlalchemy/pool.py", line 214,
> >>>>> in __init__
> >>>>>    l.first_connect(self.connection, self)
> >>>>>  File "/home/rarch/tg2env/lib/python2.6/site-packages/
> >>>>> SQLAlchemy-0.6.0-py2.6-linux-x86_64.egg/sqlalchemy/engine/
> >>>>> strategies.py", line 145, in first_connect
> >>>>>    dialect.initialize(c)
> >>>>>  File "/home/rarch/tg2env/lib/python2.6/site-packages/
> >>>>> SQLAlchemy-0.6.0-py2.6-linux-x86_64.egg/sqlalchemy/dialects/oracle/
> >>>>> base.py", line 604, in initialize
> >>>>>    super(OracleDialect, self).initialize(connection)
> >>>>>  File "/home/rarch/tg2env/lib/python2.6/site-packages/
> >>>>> SQLAlchemy-0.6.0-py2.6-linux-x86_64.egg/sqlalchemy/engine/default.py",
> >>>>> line 138, in initialize
> >>>>>    self.returns_unicode_strings =
> >>>>> self._check_unicode_returns(connection)
> >>>>>  File "/home/rarch/tg2env/lib/python2.6/site-packages/
> >>>>> SQLAlchemy-0.6.0-py2.6-linux-x86_64.egg/sqlalchemy/engine/default.py",
> >>>>> line 183, in _check_unicode_returns
> >>>>>    unicode_for_varchar = check_unicode(sqltypes.VARCHAR(60))
> >>>>>  File "/home/rarch/tg2env/lib/python2.6/site-packages/
> >>>>> SQLAlchemy-0.6.0-py2.6-linux-x86_64.egg/sqlalchemy/engine/default.py",
> >>>>> line 173, in check_unicode
> >>>>>    ]).compile(dialect=self)
> >>>>> DatabaseError: ORA-00907: missing right parenthesis
>
> >>>>> Any ideas?  Any logging we can enable to help figure this out?
>
> >>>>> Thanks in advance.
>
> >>>>> --
> >>>>> You received this message because you are subscribed to the Google 
> >>>>> Groups "sqlalchemy" group.
> >>>>> To post to this group, send email to sqlalch...@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 sqlalch...@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 sqlalch...@googlegroups.com.
> >>> To unsubscribe from this group, send email to 
> >>> sqlalchemy+unsubscr...@googlegroups.com.
> >>> For
>
> ...
>
> read more »
>
>  ora8_unicode.patch
> 1KViewDownload
>
> --
> You received this message because you are subscribed to the Google Groups 
> "sqlalchemy" group.
> To post to this group, send email to sqlalch...@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 sqlalch...@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.

Reply via email to