Where are dialect-specific optional arguments declared?

12 views
Skip to first unread message

Gord Thompson

unread,
Jan 29, 2020, 9:23:20 AM1/29/20
to sqlalchemy
For the external Firebird dialect I am trying to get the following to work. It's really identical to the Oracle equivalent, except for the dialect name, but that's my issue.

kw = {
       
"prefixes": ["GLOBAL TEMPORARY"],
       
"firebird_on_commit": "PRESERVE ROWS",
   
}
metadata
= sa.MetaData()
user_tmp
= sa.Table(
   
"user_tmp",
    metadata
,
    sa
.Column("id", sa.INT, primary_key=True),
    sa
.Column("name", sa.VARCHAR(50)),
    sa
.Column("foo", sa.INT),
    sa
.UniqueConstraint("name", name="user_tmp_uq"),
    sa
.Index("user_tmp_ix", "foo"),
   
**kw
)
metadata
.create_all(bind=engine)

I found the place in oracle/base.py (OracleDialect class) where its declarations appear to be taking place ...

construct_arguments = [
   
(
        sa_schema
.Table,
       
{"resolve_synonyms": False, "on_commit": None, "compress": False},
   
),
   
(sa_schema.Index, {"bitmap": False, "compress": False}),
]

... but when I put the same thing for "on_commit" in FBDialect and run my test code I continue to get

sqlalchemy.exc.ArgumentError: Argument 'firebird_on_commit' is not accepted by dialect 'firebird' on behalf of <class 'sqlalchemy.sql.schema.Table'>

I've tried tracing through the code when hitting an Oracle database (which works) but I'm just not seeing where 'on_commit' becomes a "thing" for the oracle dialect.

Any suggestions on where else I should look?

Mike Bayer

unread,
Jan 29, 2020, 9:54:32 AM1/29/20
to noreply-spamdigest via sqlalchemy
the whole thing happens in the sqlalchemy.sql.base.DialectKWArgs class .   That class will consume the FBDialect.construct_arguments collection directly.    It requires that the dialect is loaded through the "dialect registry" mentioned in README.dialects.rst so perhaps make sure it's loading the correct object; "firebird" is likely already matching the one that's inside of SQLAlchemy.   you might have to force your own dialect on top of it if you are sharing that name for now.





--
SQLAlchemy -
The Python SQL Toolkit and Object Relational Mapper
 
 
To post example code, please provide an MCVE: Minimal, Complete, and Verifiable Example. See http://stackoverflow.com/help/mcve for a full description.
---
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.

Reply all
Reply to author
Forward
0 new messages