You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Actual:
✔️ program finishes "successfully", but sqlalchemy log shows "swallowed" error.
ERROR:sqlalchemy.pool.impl.QueuePool:Error closing cursor: ('HY000', 'The driver did not supply an error!')
Traceback (most recent call last):
File ".../sqlalchemy-exasol/venv/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 1368, in _safe_close_cursor
cursor.close()
pyodbc.Error: ('HY000', 'The driver did not supply an error!')
sqla_regression.py
importargparseimportloggingimportosimportsysfromcontextlibimportcontextmanagerfrompathlibimportPathfromplatformimportplatformfromsubprocessimportrunfromtempfileimportTemporaryDirectoryfromtextwrapimportdedentfromsqlalchemyimportColumn, Integer, MetaData, String, Table, create_engine, textODBCINST_INI_TEMPLATE=dedent(
""" [ODBC] Trace = {trace} TraceFile = {trace_file} [EXAODBC] #Driver location will be appended in build environment: DRIVER={driver} """
)
@contextmanagerdefenvironment(env_vars):
_env=os.environ.copy()
os.environ.update(env_vars)
yieldos.environos.environ.clear()
os.environ.update(_env)
@contextmanagerdeftemporary_odbc_config(config):
withTemporaryDirectory() astmp_dir:
tmp_dir=Path(tmp_dir)
config_dir=tmp_dir/"odbcconfig"config_dir.mkdir(exist_ok=True)
config_file=config_dir/"odbcinst.ini"withopen(config_file, "w") asf:
f.write(config)
yieldconfig_file@contextmanagerdefodbcconfig(driver, log_file=None):
withtemporary_odbc_config(
ODBCINST_INI_TEMPLATE.format(
driver=driver,
trace="yes"iflog_fileisnotNoneelse"no",
trace_file=log_file,
)
) ascfg:
env_vars= {"ODBCSYSINI": f"{cfg.parent.resolve()}"}
withenvironment(env_vars) asenv:
yieldcfg, envdefsqla_sql_insert(engine):
table=setup_table(engine)
withengine.connect() asconnection:
connection.execute(text(f"INSERT INTO {table} VALUES (1, 'd1')"))
connection.execute(text(f"INSERT INTO {table} VALUES (1, 'd1')"))
defsqla_insert(engine):
table=setup_table(engine)
withengine.connect() asconnection:
connection.execute(table.insert(), {"id": 1, "data": "d1"})
connection.execute(table.insert(), {"id": 1, "data": "d1"})
defsqla_single_insert(engine):
table=setup_table(engine)
withengine.connect() asconnection:
connection.execute(table.insert(), {"id": 1, "data": "d1"})
defsetup_table(engine):
engine.execute(text("DROP TABLE IF EXISTS TEST.manual_pk"))
meta_data=MetaData()
t=Table(
"manual_pk",
meta_data,
Column("id", Integer, primary_key=True, autoincrement=False),
Column("data", String(50)),
)
meta_data.create_all(engine)
returnmeta_data.tables["manual_pk"]
defsystem_info():
print("System Information")
print("-"*50)
print("PYTHON VERSION")
run(["python", "--version"])
print("-"*50)
print("PYTHON ODBC VERSION")
run(["python", "-m", "pip", "show", "pyodbc"])
print("PLATFORM")
print(platform())
print("EXASOL ODBC DRIVER")
print("libexasolodbc driver to 7.0.11")
defcreate_parser():
parser=argparse.ArgumentParser()
parser.add_argument(
"scenario",
choices=["sqla-insert", "sqla-sql-insert", "sqla-single-insert"],
help="Test scenario to execute",
)
parser.add_argument(
"driver",
type=Path,
help="Path to the exasol odbc driver which shall be used.",
)
parser.add_argument(
"--system-info",
action="store_true",
default=False,
help="Print system information.",
)
parser.add_argument(
"--db-address",
default="localhost",
help="DNS name or address of the database server to connect to.",
)
parser.add_argument(
"--db-port", type=int, default=8888, help="Port of the database to connect to."
)
parser.add_argument(
"--logging",
action="store_true",
default=False,
help="Whether or not to enable logging",
)
parser.add_argument(
"--dialect",
choices=["pyodbc", "turbodbc"],
default="pyodbc",
help="Dialect which shall be used for the connection",
)
parser.add_argument(
"--autocommit",
action="store_true",
default=False,
help="Whether or not to store the odbc trace",
)
returnparserdefmain(argv=None):
parser=create_parser()
args=parser.parse_args(argv)
ifargs.system_info:
system_info()
ifargs.logging:
log_folder=Path(os.getcwd()) /"logs"log_folder.mkdir(exist_ok=True)
odbc_log=log_folder/"odbc.trace"exa_log=log_folder/"exa-odbc.trace"sqla_log=log_folder/"sqla.trace"logging.basicConfig(filename=f"{sqla_log}", level=logging.DEBUG)
logging.getLogger("sqlalchemy").setLevel(logging.DEBUG)
defmake_connection_url(args):
return"".join(
(
"exa+{dialect}://sys:exasol@{address}:{port}",
"/TEST?DRIVER=EXAODBC&CONNECTIONCALL=en_US.UTF-8",
f"&EXALOGFILE={exa_log}"ifargs.loggingelse"",
)
).format(dialect=args.dialect, address=args.db_address, port=args.db_port)
withodbcconfig(args.driver, f"{odbc_log}"ifargs.loggingelseNone):
url=make_connection_url(args)
engine=create_engine(url, connect_args={"autocommit": args.autocommit})
scenario= {
"sqla-insert": sqla_insert,
"sqla-sql-insert": sqla_sql_insert,
"sqla-single-insert": sqla_single_insert,
}[args.scenario]
scenario(engine)
sys.exit(0)
if__name__=="__main__":
main()
The text was updated successfully, but these errors were encountered:
The long-term goal of this project is to phase out support for ODBC. Additionally, as of today, we have not received any reports from users indicating that this issue is a problem.
Decision
Considering the strategic direction towards phasing out ODBC and the lack of user feedback on this issue, we have decided to close this ticket.
Steps To Reproduce:
Add the tests below to
test/test_suit.py
and execute the integration tests or just the test itself.(using the pyodbc connector)
Expected Behavior
✔️ Test passes because an
sqlalchemy.exec.IntegrityError
is risen.Actual Behavior
💥 Test fails because no exception is risen.
Related Issues
Regression
With the script
sqla_regression.py
the scenario can be investigated withunix-odbc
,exasol-odbc
andsqla
-logging enabled
.Dialect:
pyodbc
, Autocommit:no
Expected:
💥 sqlalchemy raises and IntegrityError
Actual:
✔️ program finishes "successfully", but sqlalchemy log shows "swallowed" error.
sqla_regression.py
The text was updated successfully, but these errors were encountered: