On 5/4/15 3:23 AM, Ofir Herzas wrote:

For some reason, I get the following error while using this attribute on the table:

python-2.7.6/lib/python2.7/site-packages/sqlalchemy/sql/schema.py:500: SAWarning: Can't validate argument 'implicit_returning'; can't locate any SQLAlchemy dialect named 'implicit'

self._validate_dialect_kwargs(kwargs)

I should note that the application I'm developing uses other DB's also (e.g mysql) nd that I got this error while checking the application on mysql.


implicit_returning is one of the core arguments of Table. That error message would happen if you were to send implicit_returning to some other kind of object, like an Index.

Here is a diff against history_meta showing where the argument would go:

diff --git a/examples/versioned_history/history_meta.py b/examples/versioned_history/history_meta.py
index 6d7b137..b5eadcb 100644
--- a/examples/versioned_history/history_meta.py
+++ b/examples/versioned_history/history_meta.py
@@ -106,7 +106,8 @@ def _history_mapper(local_mapper):
             local_mapper.local_table.name + '_history',
             local_mapper.local_table.metadata,
             *cols,
-            schema=local_mapper.local_table.schema
+            schema=local_mapper.local_table.schema,
+            implicit_returning=False
         )
     else:
# single table inheritance. take any additional columns that may have




*From:*sqlalchemy@googlegroups.com [mailto:sqlalchemy@googlegroups.com] *On Behalf Of *Mike Bayer
*Sent:* Monday, May 04, 2015 1:47 AM
*To:* sqlalchemy@googlegroups.com
*Subject:* Re: [sqlalchemy] Does anyone know how to handle "NoSuchColumnError"

On 5/3/15 12:00 PM, Ofir Herzas wrote:

    Is there any danger using the implicit_returning=False on the
    engine? Or is it the same?


not "dangerous" but the implicit returning feature is very nice for INSERT statements done by the ORM, assuming you are using sequences to generate primary key values; it saves a round trip of executing the sequence ahead of time.



*From:*sqlalchemy@googlegroups.com <mailto:sqlalchemy@googlegroups.com> [mailto:sqlalchemy@googlegroups.com] *On Behalf Of *Mike Bayer
*Sent:* Sunday, May 03, 2015 6:07 PM
*To:* sqlalchemy@googlegroups.com <mailto:sqlalchemy@googlegroups.com>
*Subject:* Re: [sqlalchemy] Does anyone know how to handle "NoSuchColumnError"

On 5/3/15 2:01 AM, Ofir Herzas wrote:

    Hi Michael,

    Thank you very much for your fast response. I will give it a try.

    I tried to remove unneeded stuff but I think that the problem is
    in the track_changes mixin as I never got this error before using it.

    If you need more stuff or do find something, I'd be happy to know.


OK, passing "implicit_returning=False" to the Table objects created by the history mixin should fix it on your end. I'll try to find some time to experiment with it.




BTW: for initialization, I use:

DB_URL="oracle://user:pass@url/db"

engine = create_engine(DB_URL, echo=False, pool_recycle=3600)

Session = scoped_session(sessionmaker(bind=engine, expire_on_commit=False))

session = tracked_session(Session())

Base = declarative_base()

Cheers,

Ofir


On Thursday, April 30, 2015 at 7:03:10 PM UTC+3, Michael Bayer wrote:

On 4/30/15 11:00 AM, Ofir Herzas wrote:

    Hi,

    I'm using sqlalchemy 0.9.7 and cx_oracle 5.1.3 and every once in a
    while (inconsistent), I get the following error:

    Traceback (most recent call last):
      File
    
"/opt/enigmai/ve/python-2.7.6/lib/python2.7/site-packages/sqlalchemy/orm/session.py",
    line 1919, in flush
        self._flush(objects)
      File
    
"/opt/enigmai/ve/python-2.7.6/lib/python2.7/site-packages/sqlalchemy/orm/session.py",
    line 2037, in _flush
        transaction.rollback(_capture_exception=True)
      File
    
"/opt/enigmai/ve/python-2.7.6/lib/python2.7/site-packages/sqlalchemy/util/langhelpers.py",
    line 60, in __exit__
        compat.reraise(exc_type, exc_value, exc_tb)
      File
    
"/opt/enigmai/ve/python-2.7.6/lib/python2.7/site-packages/sqlalchemy/orm/session.py",
    line 2001, in _flush
        flush_context.execute()
      File
    
"/opt/enigmai/ve/python-2.7.6/lib/python2.7/site-packages/sqlalchemy/orm/unitofwork.py",
    line 372, in execute
        rec.execute(self)
      File
    
"/opt/enigmai/ve/python-2.7.6/lib/python2.7/site-packages/sqlalchemy/orm/unitofwork.py",
    line 526, in execute
        uow
      File
    
"/opt/enigmai/ve/python-2.7.6/lib/python2.7/site-packages/sqlalchemy/orm/persistence.py",
    line 65, in save_obj
        mapper, table, insert)
      File
    
"/opt/enigmai/ve/python-2.7.6/lib/python2.7/site-packages/sqlalchemy/orm/persistence.py",
    line 602, in _emit_insert_statements
        execute(statement, params)
      File
    
"/opt/enigmai/ve/python-2.7.6/lib/python2.7/site-packages/sqlalchemy/engine/base.py",
    line 729, in execute
        return meth(self, multiparams, params)
      File
    
"/opt/enigmai/ve/python-2.7.6/lib/python2.7/site-packages/sqlalchemy/sql/elements.py",
    line 321, in _execute_on_connection
        return connection._execute_clauseelement(self, multiparams,
    params)
      File
    
"/opt/enigmai/ve/python-2.7.6/lib/python2.7/site-packages/sqlalchemy/engine/base.py",
    line 826, in _execute_clauseelement
        compiled_sql, distilled_params
      File
    
"/opt/enigmai/ve/python-2.7.6/lib/python2.7/site-packages/sqlalchemy/engine/base.py",
    line 978, in _execute_context
        context._fetch_implicit_returning(result)
      File
    
"/opt/enigmai/ve/python-2.7.6/lib/python2.7/site-packages/sqlalchemy/engine/default.py",
    line 815, in _fetch_implicit_returning
        ipk.append(row[c])
      File
    
"/opt/enigmai/ve/python-2.7.6/lib/python2.7/site-packages/sqlalchemy/engine/result.py",
    line 331, in _key_fallback
        expression._string_or_unprintable(key))
    NoSuchColumnError: "Could not locate column in row for column
    't_shift_employee_change.id <http://t_shift_employee_change.id>'"
    [30/Apr/2015:15:55:17] EXCEPTION
    # ---- EXCEPTION DESCRIPTION BEGIN ---- #
    # ---- Type ---- #
    NoSuchColumnError
    # ---- Detail ---- #
    "Could not locate column in row for column
    't_shift_employee_change.id <http://t_shift_employee_change.id>'"
    # ---- Traceback ---- #
      File
    
"/opt/enigmai/ve/python-2.7.6/lib/python2.7/site-packages/sqlalchemy/orm/session.py",
    line 1919, in flush
        self._flush(objects)
    -
      File
    
"/opt/enigmai/ve/python-2.7.6/lib/python2.7/site-packages/sqlalchemy/orm/session.py",
    line 2037, in _flush
        transaction.rollback(_capture_exception=True)
    -
      File
    
"/opt/enigmai/ve/python-2.7.6/lib/python2.7/site-packages/sqlalchemy/util/langhelpers.py",
    line 60, in __exit__
        compat.reraise(exc_type, exc_value, exc_tb)
    -
      File
    
"/opt/enigmai/ve/python-2.7.6/lib/python2.7/site-packages/sqlalchemy/orm/session.py",
    line 2001, in _flush
        flush_context.execute()
    -
      File
    
"/opt/enigmai/ve/python-2.7.6/lib/python2.7/site-packages/sqlalchemy/orm/unitofwork.py",
    line 372, in execute
        rec.execute(self)
    -
      File
    
"/opt/enigmai/ve/python-2.7.6/lib/python2.7/site-packages/sqlalchemy/orm/unitofwork.py",
    line 526, in execute
        uow
    -
      File
    
"/opt/enigmai/ve/python-2.7.6/lib/python2.7/site-packages/sqlalchemy/orm/persistence.py",
    line 65, in save_obj
        mapper, table, insert)
    -
      File
    
"/opt/enigmai/ve/python-2.7.6/lib/python2.7/site-packages/sqlalchemy/orm/persistence.py",
    line 602, in _emit_insert_statements
        execute(statement, params)
    -
      File
    
"/opt/enigmai/ve/python-2.7.6/lib/python2.7/site-packages/sqlalchemy/engine/base.py",
    line 729, in execute
        return meth(self, multiparams, params)
    -
      File
    
"/opt/enigmai/ve/python-2.7.6/lib/python2.7/site-packages/sqlalchemy/sql/elements.py",
    line 321, in _execute_on_connection
        return connection._execute_clauseelement(self, multiparams,
    params)
    -
      File
    
"/opt/enigmai/ve/python-2.7.6/lib/python2.7/site-packages/sqlalchemy/engine/base.py",
    line 826, in _execute_clauseelement
        compiled_sql, distilled_params
    -
      File
    
"/opt/enigmai/ve/python-2.7.6/lib/python2.7/site-packages/sqlalchemy/engine/base.py",
    line 978, in _execute_context
        context._fetch_implicit_returning(result)
    -
      File
    
"/opt/enigmai/ve/python-2.7.6/lib/python2.7/site-packages/sqlalchemy/engine/default.py",
    line 815, in _fetch_implicit_returning
        ipk.append(row[c])
    -
      File
    
"/opt/enigmai/ve/python-2.7.6/lib/python2.7/site-packages/sqlalchemy/engine/result.py",
    line 331, in _key_fallback
        expression._string_or_unprintable(key))

    # ---- EXCEPTION DESCRIPTION END ---- #

    I saw several posts about this issue but I didn't find a solution.

    Restarting my service seems to fix the issue for a while.

    BTW: This error is linked to a mixin class I've created for
    track-changes based on the version mixin from

    
/http://docs.sqlalchemy.org/en/latest/_modules/examples/versioned_history/history_meta.html/


this error refers to a wide variety of situations where the ORM is running a query that is failing to compose correctly. It's a bug in SQLAlchemy. That you are getting this within an INSERT statement from the RETURNING clause in oracle strongly suggests this is a bug in the Oracle dialect. If you can post minimal mappings and the stack trace here as a bug report that would be very helpful.

Note also that the Oracle dialect doesn't do very well with composite primary keys in conjunction with RETURNING. There may have been some limitations I came across in my testing here, so there is a note at http://docs.sqlalchemy.org/en/rel_1_0/dialects/oracle.html#returning-support regarding this. While I still want to know how you're getting exactly this kind of error since it would be nice to anticipate it better, the section here illustrates the implicit_returnining=False flag that would resolve these errors you're getting.





--
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 <javascript:>. To post to this group, send email to sqlal...@googlegroups.com <mailto: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 the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com <mailto:sqlalchemy+unsubscr...@googlegroups.com>. To post to this group, send email to sqlalchemy@googlegroups.com <mailto:sqlalchemy@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/TpJ86vA64DM/unsubscribe. To unsubscribe from this group and all its topics, send an email to sqlalchemy+unsubscr...@googlegroups.com <mailto:sqlalchemy+unsubscr...@googlegroups.com>. To post to this group, send email to sqlalchemy@googlegroups.com <mailto:sqlalchemy@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 the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com <mailto:sqlalchemy+unsubscr...@googlegroups.com>. To post to this group, send email to sqlalchemy@googlegroups.com <mailto:sqlalchemy@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/TpJ86vA64DM/unsubscribe. To unsubscribe from this group and all its topics, send an email to sqlalchemy+unsubscr...@googlegroups.com <mailto:sqlalchemy+unsubscr...@googlegroups.com>. To post to this group, send email to sqlalchemy@googlegroups.com <mailto:sqlalchemy@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 the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com <mailto:sqlalchemy+unsubscr...@googlegroups.com>. To post to this group, send email to sqlalchemy@googlegroups.com <mailto:sqlalchemy@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 the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to