Re: [sqlalchemy] Re: sqla 0.6.0 with oracle 8 (ORA-00907: missing right parenthesis)

2010-05-18 Thread Michael Bayer

On May 18, 2010, at 11:31 AM, Kent wrote:

 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

OK we can't do that since that module assumes no DBAPI, but my fix is wrong 
because its calling the cursor directly and our own DBAPIError wrapping isn't 
taking effect.  We'd have to use plain Exception.

 
 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?

I don't know that that's the case. Oracle 8 client library does unicode 
AFAIK the same as versions which are higher, and I'm not sure if here the 
behavior would be different if you had NLS_LANG set, for example.

The statement that is running the second time around should be:

SELECT CAST('test unicode returns' AS NVARCHAR(60)) AS anon_1 FROM DUAL

then it seems like either that fails directly, or it fails when the client gets 
a hold of it.   See what happens with that statement.   Not sure that Oracle 8 
has NVARCHAR which might be the issue.




-- 
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.



Re: [sqlalchemy] Re: sqla 0.6.0 with oracle 8 (ORA-00907: missing right parenthesis)

2010-05-18 Thread Michael Bayer
Sorry, I meant NVARCHAR2.   

SELECT CAST('test unicode returns' AS NVARCHAR2(60)) AS anon_1 FROM DUAL

works ?  or no ?



On May 18, 2010, at 12:17 PM, Kent wrote:

 Oops, my bad, I didn't notice you that statement changed NVARCHAR2 to
 NVARCHAR:
 
 Here is that result:
 =
 SQL SELECT CAST('test unicode returns' AS NVARCHAR(60)) AS anon_1
 FROM DUAL
  2  ;
 SELECT CAST('test unicode returns' AS NVARCHAR(60)) AS anon_1 FROM
 DUAL
  *
 ERROR at line 1:
 ORA-00907: missing right parenthesis
 =
 
 
 
 
 On May 18, 12:15 pm, Kent k...@retailarchitects.com wrote:
 SELECT CAST('test unicode returns' AS NVARCHAR(60)) AS anon_1 FROM DUAL
 
 then it seems like either that fails directly, or it fails when the client 
 gets a hold of it.   See what happens with that statement.   Not sure that 
 Oracle 8 has NVARCHAR which might be the issue.
 
 Please see the beginning of my previous post, that is the statement
 creating the ORA-12704: character set mismatch
 
 So, you intend to change exc.DBAPIError to Exception? (That is
 actually exactly what I had just done as a workaround until I heard
 back from you)
 
 --
 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.
 

-- 
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.



Re: [sqlalchemy] Re: sqla 0.6.0 with oracle 8 (ORA-00907: missing right parenthesis)

2010-05-18 Thread Kent Bower

No, this is what was causing ORA-12704: character set mismatch:

SQL SELECT CAST('test unicode returns' AS NVARCHAR2(60)) AS anon_1 FROM 
DUAL;

SELECT CAST('test unicode returns' AS NVARCHAR2(60)) AS anon_1 FROM DUAL
*
ERROR at line 1:
ORA-12704: character set mismatch







On 5/18/2010 1:17 PM, Michael Bayer wrote:

Sorry, I meant NVARCHAR2.

SELECT CAST('test unicode returns' AS NVARCHAR2(60)) AS anon_1 FROM DUAL

works ?  or no ?



On May 18, 2010, at 12:17 PM, Kent wrote:

   

Oops, my bad, I didn't notice you that statement changed NVARCHAR2 to
NVARCHAR:

Here is that result:
=
SQL  SELECT CAST('test unicode returns' AS NVARCHAR(60)) AS anon_1
FROM DUAL
  2  ;
SELECT CAST('test unicode returns' AS NVARCHAR(60)) AS anon_1 FROM
DUAL
  *
ERROR at line 1:
ORA-00907: missing right parenthesis
=




On May 18, 12:15 pm, Kentk...@retailarchitects.com  wrote:
 

SELECT CAST('test unicode returns' AS NVARCHAR(60)) AS anon_1 FROM DUAL
 
   

then it seems like either that fails directly, or it fails when the client gets 
a hold of it.   See what happens with that statement.   Not sure that Oracle 8 
has NVARCHAR which might be the issue.
 

Please see the beginning of my previous post, that is the statement
creating the ORA-12704: character set mismatch

So, you intend to change exc.DBAPIError to Exception? (That is
actually exactly what I had just done as a workaround until I heard
back from you)

--
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.

 
   


--
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.



Re: [sqlalchemy] Re: sqla 0.6.0 with oracle 8 (ORA-00907: missing right parenthesis)

2010-05-18 Thread Michael Bayer
latest patch - also try not specifiying use_ansi=False, it should detect that 
now






On May 18, 2010, at 2:04 PM, Kent wrote:

 It specifically says NCHAR is not usable *for unicode* until Oracle
 9i.  (Showing my ignorance here: are you certain NVARCHAR2 uses
 NCHAR?  Seems logical to me.)
 
 The white paper further states: No Unicode character set is supported
 as the national character set prior to Oracle 9i.  I believe the N
 in NVARCHAR2 stands for national so my best guess is you are correct
 that NVARCHAR2 is useless in oracle 8 (as far as Unicode is
 concerned).
 
 
 I caught the Exception as we discussed earlier and then set
 unicode_for_unicode = False in engine/default.py.
 
 Now I'm getting a problem later with unicode:
 
 Traceback (most recent call last):
  File /home/rarch/tg2env/bin/paster, line 8, in module
load_entry_point('PasteScript==1.7.3', 'console_scripts', 'paster')
 ()
  File /home/rarch/tg2env/lib/python2.6/site-packages/
 PasteScript-1.7.3-py2.6.egg/paste/script/command.py, line 84, in run
invoke(command, command_name, options, args[1:])
  File /home/rarch/tg2env/lib/python2.6/site-packages/
 PasteScript-1.7.3-py2.6.egg/paste/script/command.py, line 123, in
 invoke
exit_code = runner.run(args)
  File /home/rarch/tg2env/lib/python2.6/site-packages/
 PasteScript-1.7.3-py2.6.egg/paste/script/appinstall.py, line 68, in
 run
return super(AbstractInstallCommand, self).run(new_args)
  File /home/rarch/tg2env/lib/python2.6/site-packages/
 PasteScript-1.7.3-py2.6.egg/paste/script/command.py, line 218, in run
result = self.command()
  File /home/rarch/tg2env/lib/python2.6/site-packages/
 PasteScript-1.7.3-py2.6.egg/paste/script/appinstall.py, line 456, in
 command
self, config_file, section,
 self.sysconfig_install_vars(installer))
  File /home/rarch/tg2env/lib/python2.6/site-packages/
 PasteScript-1.7.3-py2.6.egg/paste/script/appinstall.py, line 598, in
 setup_config
mod.setup_app, command, filename, section, vars)
  File /home/rarch/tg2env/lib/python2.6/site-packages/
 PasteScript-1.7.3-py2.6.egg/paste/script/appinstall.py, line 612, in
 _call_setup_app
func(command, conf, vars)
  File /home/rarch/trunk/src/appserver/pylotengine/websetup.py, line
 32, in setup_app
 
 model.metadata.create_all(bind=config['pylons.app_globals'].sa_engine)
  File /home/rarch/tg2env/lib/python2.6/site-packages/
 SQLAlchemy-0.6.0.1-py2.6-linux-x86_64.egg/sqlalchemy/schema.py, line
 1958, in create_all
bind.create(self, checkfirst=checkfirst, tables=tables)
  File /home/rarch/tg2env/lib/python2.6/site-packages/
 SQLAlchemy-0.6.0.1-py2.6-linux-x86_64.egg/sqlalchemy/engine/base.py,
 line 1504, in create
self._run_visitor(ddl.SchemaGenerator, entity,
 connection=connection, **kwargs)
  File /home/rarch/tg2env/lib/python2.6/site-packages/
 SQLAlchemy-0.6.0.1-py2.6-linux-x86_64.egg/sqlalchemy/engine/base.py,
 line 1535, in _run_visitor
visitorcallable(self.dialect, conn,
 **kwargs).traverse_single(element)
  File /home/rarch/tg2env/lib/python2.6/site-packages/
 SQLAlchemy-0.6.0.1-py2.6-linux-x86_64.egg/sqlalchemy/sql/visitors.py,
 line 77, in traverse_single
return meth(obj, **kw)
  File /home/rarch/tg2env/lib/python2.6/site-packages/
 SQLAlchemy-0.6.0.1-py2.6-linux-x86_64.egg/sqlalchemy/engine/ddl.py,
 line 36, in visit_metadata
collection = [t for t in sql_util.sort_tables(tables) if
 self._can_create(t)]
  File /home/rarch/tg2env/lib/python2.6/site-packages/
 SQLAlchemy-0.6.0.1-py2.6-linux-x86_64.egg/sqlalchemy/engine/ddl.py,
 line 29, in _can_create
return not self.checkfirst or not
 self.dialect.has_table(self.connection, table.name,
 schema=table.schema)
  File /home/rarch/tg2env/lib/python2.6/site-packages/
 SQLAlchemy-0.6.0.1-py2.6-linux-x86_64.egg/sqlalchemy/dialects/oracle/
 base.py, line 626, in has_table
name=self.denormalize_name(table_name),
 schema_name=self.denormalize_name(schema))
  File /home/rarch/tg2env/lib/python2.6/site-packages/
 SQLAlchemy-0.6.0.1-py2.6-linux-x86_64.egg/sqlalchemy/engine/base.py,
 line 1109, in execute
return Connection.executors[c](self, object, multiparams, params)
  File /home/rarch/tg2env/lib/python2.6/site-packages/
 SQLAlchemy-0.6.0.1-py2.6-linux-x86_64.egg/sqlalchemy/engine/base.py,
 line 1186, in _execute_clauseelement
return self.__execute_context(context)
  File /home/rarch/tg2env/lib/python2.6/site-packages/
 SQLAlchemy-0.6.0.1-py2.6-linux-x86_64.egg/sqlalchemy/engine/base.py,
 line 1215, in __execute_context
context.parameters[0], context=context)
  File /home/rarch/tg2env/lib/python2.6/site-packages/
 SQLAlchemy-0.6.0.1-py2.6-linux-x86_64.egg/sqlalchemy/engine/base.py,
 line 1284, in _cursor_execute
self._handle_dbapi_exception(e, statement, parameters, cursor,
 context)
  File /home/rarch/tg2env/lib/python2.6/site-packages/
 SQLAlchemy-0.6.0.1-py2.6-linux-x86_64.egg/sqlalchemy/engine/base.py,
 line 1282, in _cursor_execute
self.dialect.do_execute(cursor, statement, 

Re: [sqlalchemy] Re: sqla 0.6.0 with oracle 8 (ORA-00907: missing right parenthesis)

2010-05-17 Thread Michael Bayer
what do you get for engine.dialect.supports_char_length, 
engine.dialect.server_version_info ?


On May 17, 2010, at 4:56 PM, Kent 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