Thanks mike!

I understand that it should work when querying over SQLAlchemy API. the 
missing part of my use case I forgot to provide is, it only uses 
Alembic/SQLAlchemy to manage schema changes, while the actual query may 
comes from other query engine like a dashboard, a desktop DB client or a 
notebook where data scientists knows SQL only, the name cases would force 
user to remember such convention from DB design (unpleasant part when 
switching RDBMS).

A simple question is, if it already created tables via Alembic migration 
with uppercase table names, is there any API in Alembic simply support the 
statement like `ALTER TABLE XXX_YYY_ZZZ RENAME TO xxx_yyy_zzz`? Since I 
noticed that the revision autogenerate is not sensitive to table name. 
should I manually create a revision for postgres only?

On Monday, January 4, 2021 at 6:57:33 PM UTC-5 mik...@zzzcomputing.com 
wrote:

> This is the casing convention of the database and SQLAlchemy does not 
> consider the name to be in "uppercase" or "lowercase" (or even "mixed 
> case") but rather "case insensitive", which really means the name is 
> referred towards without any quoting.    When no quoting is applied, there 
> is essentially no "casing" at all to the identifier that is stored by the 
> database.
>
> When you refer to the table name in SQLAlchemy, such as in a Table() 
> object, or in Alembic as in op.create_table(), refer to it as all lower 
> case at all times in the Python code- this indicates to SQLAlchemy that 
> this is a case insensitive name and should not be quoted (as long as it has 
> no special characters, spaces, etc).  SQLAlchemy will automatically render 
> the name without quotes in DDL, DML and DQL, and render it as UPPERCASE 
> when it queries DB2's catalogs, and as lower case when it queries 
> PostgreSQL's catalogs.
>
>
> On Mon, Jan 4, 2021, at 4:12 PM, Ke Zhu - kz...@us.ibm.com wrote:
>
> The use case is migrating data from a Db2 instance (where schema is not
> managed under Alembic migration) to a postgresql instance (where I plan
> to manage schema via Alembic).
>
> In Db2, by default, it stores unquoted mixed case identifiers in
> Uppercase. While the postgres I got it stores unquoted mixed case
> indetifiers in lowercase. So If I plan to keep such convention in
> postgres (store unquoted mixed case identifiers like table name in
> lowercase), what's the suggested practice to migrate an existing table
> like "XXX_YYY_ZZZ" to "xxx_yyy_zzz"?
>
> -- 
> You received this message because you are subscribed to the Google Groups 
> "sqlalchemy-alembic" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to sqlalchemy-alem...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/sqlalchemy-alembic/5d4bf2d1f07e6958f94ee08d941db96c96fd91f0.camel%40us.ibm.com
> .
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy-alembic" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy-alembic+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sqlalchemy-alembic/ca3b7c29-5309-4292-85bd-f64c6330da15n%40googlegroups.com.

Reply via email to