Re: [sqlalchemy] Re: Sql alchemy-Oracle Error
Hi SORRY for the delay to reply. Here is what my definitions. These are my class and table definitions: class Task(DeclarativeBase): task_id = Column(Integer,Sequence('id_ seq'), primary_key=True) task_type = Column(Unicode(50), default=to_unicode('Task')) name = Column(Unicode(256)) entity_id = Column(Unicode(256)) entity_name = Column(Unicode(50)) context = Column(PickleType) params = Column(PickleType) kw_params = Column(PickleType) processors = Column(ImmutablePickleType) class TaskCalendar(DeclarativeBase): __tablename__ = 'task_calendars1' cal_id = Column(Integer,Sequence('id_ seq'), primary_key=True) task_id = Column(Integer, ForeignKey('tasks.task_id')) dow = Column(Integer) month = Column(Integer) day = Column(Integer) hour = Column(Integer) minute = Column(Integer) task = relation(Task, backref=backref('calendar') _tablename_=tasks TASK_ID Number TASK_TYPEVarchar2 NAME Varchar2 ENTITY_IDVarchar2 ENTITY_NAME Varchar2 CONTEXT Blob PARAMS Blob KW_PARAMSBlob PROCESSORS Blob task = relation(Task, backref=backref('calendar')) This is the query what am trying to do. tasks=DBSession..query(TaskCalendar).options(eagerload('task')).\ filter((TaskCalendar.dow == 0) |\ TaskCalendar.dow.op('')(1 now[6]) 0) (3)SELECT task_calendars.cal_id AS task_calendars_cal_id, task_calendars.task_id AS task_calendars_task_id, task_calendars.dow AS task_calendars_dow, task_calendars.month AS task_calendars_month, task_calendars.day AS task_calendars_day, task_calendars.hour AS task_calendars_hour, task_calendars.minute AS task_calendars_minute, tasks_1.task_id AS tasks_1_task_id, tasks_1.task_type AS tasks_1_task_type, tasks_1.name AS tasks_1_name, tasks_1.entity_id AS tasks_1_entity_id, tasks_1.entity_name AS tasks_1_entity_name, tasks_1.context AS tasks_1_context, tasks_1.params AS tasks_1_params, tasks_1.kw_params AS tasks_1_kw_params, tasks_1.processors AS tasks_1_processors, tasks_1.user_name AS tasks_1_user_name, tasks_1.submitted_on AS tasks_1_submitted_on, tasks_1.repeating AS tasks_1_repeating FROM task_calendars LEFT OUTER JOIN tasks tasks_1 ON tasks_1.task_id = task_calendars.task_id I have the Blob error with thease ORA-00932: inconsistent datatypes: expected NUMBER got BLOB HELP ME TO FIX THESE PROBLEM THANKS -- 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.
[sqlalchemy] Re: Sql alchemy-Oracle Error
Hi task = Task(u'Task',\ {'quiet':False}, [], {}, None, u'admin') model.DBSession.merge(task) in my database the following query will try to select the above task object and result in error DBSession.query(TaskCalendar).options(eagerload('task')).\ filter((TaskCalendar.dow == 0) |\ TaskCalendar.dow.op('')(1 now[6]) 0).filter(TaskCalendar.task_id == 19).all() thanks -- 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.
[sqlalchemy] Re: declarative + order_by of 2 columns: is it possible?
Hi, On 11 Mag, 18:23, sandro dentella san...@e-den.it wrote: Hi, i have a working declarative configuration that has a relation as this:: client = relation(Cliente, backref='jobs' , lazy=False, order_by=status.desc) now I'd like to add a second column in the order_by field but adding a list doesn't seem to work. I tried: client = relation(Cliente, backref='jobs' , lazy=False, order_by=[status.desc, description]) before posting the error I'd like to understand if that should be correct as I don't find in the docs the correct syntax, I just find the syntax for order_by method of query. sorry for reposting, but I can't even understnd if the above syntax should be allowed or not. According to docs for 'relation': order_by – indicates the ordering that should be applied when loading these items. doesn't meant it accepts more than one column, order_by for query does... It's not vital but I'd like to know if it's possible and I'm just misinterpreting the syntax. thanks sandro -- 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.
[sqlalchemy] Re: sqla 0.6.0 with oracle 8 (ORA-00907: missing right parenthesis)
Ignore everything below unicode_for_unicode = False for Oracle lower than 9? in previous post, I meant to delete those lines -- 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.
[sqlalchemy] Re: is sqlalchemy-migrate the right way to go?
This thread is of interest to me as well, although the problem I'm facing is somewhat different. Just to expand the space a little, here's my situation: - A legacy database schema with hundreds of tables and procedures. - An application that accesses the database, with occasional updates delivered to customers (not all of them will upgrade at once) -- each update needs to update the database as well as part of the installation (with live data existing in the database, of course). - Customers may add some of their own tables and procs, and have custom versions of some standard procs. (Maintaining those is the customer's problem, although we do help.) To bring some sanity to this, I've created a folder hierarchy of scripts and some programs to apply them to create or update a DB (I call it the Standard Database). This hierarchy is under version control. Still, though, it's too unwieldy to distribute and manage, and doesn't solve all the problems. Currently, we just have a folder of scripts associated with each update and run them against the customer's DB. This leaves us with the duplicate script problem, of course; sigh. I'd like to turn the Standard Database into an application that would do the kinds of things being discussed here, in particular upgrading a DB as appropriate, while respecting both the live data and local modifications. Part of this would be something like a DB diff that could let the user know what needs to be updated. Just a brain dump at this point, -- Don Dwiggins Advanced Publishing Technology -- 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)
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.
[sqlalchemy] Re: sqla 0.6.0 with oracle 8 (ORA-00907: missing right parenthesis)
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 at http://groups.google.com/group/sqlalchemy?hl=en.
[sqlalchemy] Re: sqla 0.6.0 with oracle 8 (ORA-00907: missing right parenthesis)
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.
Re: [sqlalchemy] Re: sqla 0.6.0 with oracle 8 (ORA-00907: missing right parenthesis)
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)
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.
[sqlalchemy] Re: sqla 0.6.0 with oracle 8 (ORA-00907: missing right parenthesis)
There is a fairly short Oracle-published white paper on Unicode support here: http://www.oracle.com/technology/tech/globalization/pdf/TWP_AppDev_Unicode_10gR2.pdf It does state that starting with Oracle7 there was Unicode support and lists a table of Oracle version, Character set and Unicode version. It also states you can *not* store Unicode in the NCHAR datatype until Oracle 9i. On May 18, 1:23 pm, Kent Bower k...@retailarchitects.com wrote: 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 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 more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
[sqlalchemy] Re: Is multi-level polymorphism possible in SQLAlchemy?
Don't use None for the Column type (i.e., detected as the null type). Put the type explicitly. This has been updated in the documentation recently since the None feature can't be fully supported at this time. On May 18, 2010, at 1:34 PM, Kiran Jonnalagadda wrote: Is it possible to have multi-level polymorphism in SQLAlchemy? Here's an example: class Entity(Base): __tablename__ = 'entities' id = Column(Integer, primary_key=True) created_at = Column(DateTime, default=datetime.utcnow, nullable=False) entity_type = Column(Unicode(20), nullable=False) __mapper_args__ = {'polymorphic_on': entity_type} class File(Entity): __tablename__ = 'files' id = Column(None, ForeignKey('entities.id'), primary_key=True) filepath = Column(Unicode(255), nullable=False) file_type = Column(Unicode(20), nullable=False) __mapper_args__ = {'polymorphic_identity': u'file', 'polymorphic_on': file_type) class Image(File): __mapper_args__ = {'polymorphic_identity': u'image'} __tablename__ = 'images' id = Column(None, ForeignKey('files.id'), primary_key=True) width = Column(Integer) height = Column(Integer) When I call Base.metadata.create_all(), SQLAlchemy raises the following error: NotImplementedError: Can't generate DDL for the null type. This error goes away if I remove the Image model. What gives? I sense that declaring both polymorphic_identity and polymorphic_on in File isn't doing the expected thing, but I'm not sure how else to do this. -- 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.
[sqlalchemy] Re: sqla 0.6.0 with oracle 8 (ORA-00907: missing right parenthesis)
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, parameters, context=context) File /home/rarch/tg2env/lib/python2.6/site-packages/ SQLAlchemy-0.6.0.1-py2.6-linux-x86_64.egg/sqlalchemy/engine/ default.py, line 281, in do_execute
Re: [sqlalchemy] Re: sqla 0.6.0 with oracle 8 (ORA-00907: missing right parenthesis)
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,
[sqlalchemy] default value in multiple insert
I found a similar thread from about a year ago (http:// groups.google.com/group/sqlalchemy/browse_thread/thread/ 66ef04fd10fd2be/ec7784b70abedabe), but it never seemed to answer the most burning question: is there a way in sqlalchemy to do a multiple insert with default values for unspecified columns? One way this might be possible in SQL is to use the DEFAULT keyword, but I haven't found anything about it in sqlalchemy. Below I have SQL that shows: a) the current response of sqlalchemy to a multiple insert with a row dict missing a value for a column. b) the usage of the DEFAULT keyword I am referring to mysql create table testytest ( mycol int(11) default 5 ); Query OK, 0 rows affected (0.00 sec) mysql insert into testytest (mycol) values (NULL); Query OK, 1 row affected (0.00 sec) mysql insert into testytest (mycol) values (DEFAULT); Query OK, 1 row affected (0.00 sec) mysql insert into testytest (mycol) values (12); Query OK, 1 row affected (0.00 sec) mysql select * from testytest; +---+ | mycol | +---+ | NULL | | 5 | |12 | +---+ 3 rows in set (0.00 sec) This is trivial seeming in the single insert case, but it seems like in the multiple insert case, sqlalchemy will require me to use NULLable columns and ignore defaults. Am I missing something? -- 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: Sql alchemy-Oracle Error
attached is a test program that is of a format which allows us to be able to answer your questions quickly. It is a short test program that runs fully, using the model fragments you've sent along. It does not reproduce your error. Instead, it appears that the is not an operator accepted by Oracle. Removing the reference to '' allows the program to complete successfully with both 0.6 and 0.5.8, and there is no issue with BLOB/pickletype. If you can modify this attached script to reproduce your issue, that would communicate to us what the problem is. OTOH if this script itself fails without changes, then something is up with your environment or cx_oracle install. On May 18, 2010, at 5:29 AM, dhanil anupurath wrote: Hi SORRY for the delay to reply. Here is what my definitions. These are my class and table definitions: class Task(DeclarativeBase): task_id = Column(Integer,Sequence('id_ seq'), primary_key=True) task_type = Column(Unicode(50), default=to_unicode('Task')) name = Column(Unicode(256)) entity_id = Column(Unicode(256)) entity_name = Column(Unicode(50)) context = Column(PickleType) params = Column(PickleType) kw_params = Column(PickleType) processors = Column(ImmutablePickleType) class TaskCalendar(DeclarativeBase): __tablename__ = 'task_calendars1' cal_id = Column(Integer,Sequence('id_ seq'), primary_key=True) task_id = Column(Integer, ForeignKey('tasks.task_id')) dow = Column(Integer) month = Column(Integer) day = Column(Integer) hour = Column(Integer) minute = Column(Integer) task = relation(Task, backref=backref('calendar') _tablename_=tasks TASK_ID Number TASK_TYPEVarchar2 NAME Varchar2 ENTITY_IDVarchar2 ENTITY_NAME Varchar2 CONTEXT Blob PARAMS Blob KW_PARAMSBlob PROCESSORS Blob task = relation(Task, backref=backref('calendar')) This is the query what am trying to do. tasks=DBSession..query(TaskCalendar).options(eagerload('task')).\ filter((TaskCalendar.dow == 0) |\ TaskCalendar.dow.op('')(1 now[6]) 0) (3)SELECT task_calendars.cal_id AS task_calendars_cal_id, task_calendars.task_id AS task_calendars_task_id, task_calendars.dow AS task_calendars_dow, task_calendars.month AS task_calendars_month, task_calendars.day AS task_calendars_day, task_calendars.hour AS task_calendars_hour, task_calendars.minute AS task_calendars_minute, tasks_1.task_id AS tasks_1_task_id, tasks_1.task_type AS tasks_1_task_type, tasks_1.name AS tasks_1_name, tasks_1.entity_id AS tasks_1_entity_id, tasks_1.entity_name AS tasks_1_entity_name, tasks_1.context AS tasks_1_context, tasks_1.params AS tasks_1_params, tasks_1.kw_params AS tasks_1_kw_params, tasks_1.processors AS tasks_1_processors, tasks_1.user_name AS tasks_1_user_name, tasks_1.submitted_on AS tasks_1_submitted_on, tasks_1.repeating AS tasks_1_repeating FROM task_calendars LEFT OUTER JOIN tasks tasks_1 ON tasks_1.task_id = task_calendars.task_id I have the Blob error with thease ORA-00932: inconsistent datatypes: expected NUMBER got BLOB HELP ME TO FIX THESE PROBLEM THANKS -- 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. On May 18, 2010, at 5:29 AM, dhanil anupurath wrote:Hi SORRY for the delay to reply. Here is what my definitions.These are my class and table definitions: class Task(DeclarativeBase): task_id = Column(Integer,Sequence('id_seq'), primary_key=True) task_type = Column(Unicode(50), default=to_unicode('Task')) name = Column(Unicode(256)) entity_id = Column(Unicode(256)) entity_name = Column(Unicode(50)) context = Column(PickleType) params = Column(PickleType) kw_params = Column(PickleType) processors = Column(ImmutablePickleType)class TaskCalendar(DeclarativeBase): __tablename__ = 'task_calendars1' cal_id = Column(Integer,Sequence('id_seq'), primary_key=True) task_id = Column(Integer, ForeignKey('tasks.task_id')) dow = Column(Integer) month =
Re: [sqlalchemy] default value in multiple insert
not sure what the question is - how to use server-side defaults ?Column accepts a server_default keyword for this purpose.You leave the key out of the columns dictionary for those columns where you want the server_default to fire off. if the question is, I want to multiple insert like [{'a':1, 'b':2, 'c':3}, {'a':2}, {'a':3, 'b':4}], etc. only some dictionaries are missing different keys, that is not allowed. The structure of the SQL statement as parsed by MySQL determines for which columns the server-side default is emitted and there is only one version of that with an executemany. So every param dictionary must have at least all the keys which the first one does. SQLAlchemy also allows client side defaults, but the rules are the same for executemany(), since SQLalchemy wants to keep the behaviors consistent and doesn't want to spend time scanning through the parameter list if its not needed. On May 18, 2010, at 6:53 PM, Dan K wrote: I found a similar thread from about a year ago (http:// groups.google.com/group/sqlalchemy/browse_thread/thread/ 66ef04fd10fd2be/ec7784b70abedabe), but it never seemed to answer the most burning question: is there a way in sqlalchemy to do a multiple insert with default values for unspecified columns? One way this might be possible in SQL is to use the DEFAULT keyword, but I haven't found anything about it in sqlalchemy. Below I have SQL that shows: a) the current response of sqlalchemy to a multiple insert with a row dict missing a value for a column. b) the usage of the DEFAULT keyword I am referring to mysql create table testytest ( mycol int(11) default 5 ); Query OK, 0 rows affected (0.00 sec) mysql insert into testytest (mycol) values (NULL); Query OK, 1 row affected (0.00 sec) mysql insert into testytest (mycol) values (DEFAULT); Query OK, 1 row affected (0.00 sec) mysql insert into testytest (mycol) values (12); Query OK, 1 row affected (0.00 sec) mysql select * from testytest; +---+ | mycol | +---+ | NULL | | 5 | |12 | +---+ 3 rows in set (0.00 sec) This is trivial seeming in the single insert case, but it seems like in the multiple insert case, sqlalchemy will require me to use NULLable columns and ignore defaults. Am I missing something? -- 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] default value in multiple insert
My apologies; I expressed my question rather incoherently. if the question is, I want to multiple insert like [{'a':1, 'b':2, 'c':3}, {'a':2}, {'a':3, 'b':4}], etc. only some dictionaries are missing different keys, that is not allowed. The structure of the SQL statement as parsed by MySQL determines for which columns the server-side default is emitted and there is only one version of that with an executemany. So every param dictionary must have at least all the keys which the first one does. This was the basic scenario of my question. However, unless I misunderstand, it does seem to be allowed: the missing values are replaced with NULL in the generated query. But what I actually meant to ask was this: sqlalchemy handles missing dictionary entries as NULL for the purpose of inserts, is there an easy way to have it generate a SQL statement with DEFAULT for missing dictionary entries? Eg. execute(testtable.insert(), [{'a':1, 'b':2, 'c':3}, {'a':2}, {'a':3, 'b':4}]) = INSERT INTO testtable (a,b,c) VALUES (1,2,3),(2,DEFAULT,DEFAULT),(3,4,DEFAULT) -- 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.