pyodbc.Error: ('HY000', '[HY000] [IBM][System i Access ODBC Driver][DB2 for i5/OS]SQL5051 - Qualifier SQLALCHEMY not same as name TEST_SCHEMA. (-5051) (SQLExecDirectW)')
This is caused by the constraint name not being schema-qualified and the table schema doesn't match the default schema:
CREATE TABLE test_schema.sa_cc (
a INTEGER,
CONSTRAINT "MyCkConst" CHECK (a = 1 OR (a > 2 AND a < 5))
)
This is caused by the constraint name not being schema-qualified and the table schema doesn't match the default schema:
We will have to modify DB2IdentifierPreparer to override the
format_constraintfunction which adds the schema.See https://github.com/sqlalchemy/sqlalchemy/blob/0c6e2f39df1e6748a916fc5f5a1a3b3296aed4af/lib/sqlalchemy/sql/compiler.py#L8219-L8222 for how to get the schema and default format_constraint is https://github.com/sqlalchemy/sqlalchemy/blob/0c6e2f39df1e6748a916fc5f5a1a3b3296aed4af/lib/sqlalchemy/sql/compiler.py#L8133