Hello,

I’m curious to get recommendations about the following use-case (based on this 
SO Answer 
<https://stackoverflow.com/questions/50927740/sqlalchemy-create-schema-if-not-exists#55345404>
):

*>>> import sqlalchemy*
*>>> configuration = {'sqlalchemy.url': 
'postgresql+psycopg2://postgres:postgres@localhost/test_db'}*

*>>> engine = sqlalchemy.engine_from_config(configuration, future=True)*







*>>> engine.dialect.has_schema(engine, schema)Traceback (most recent call 
last):  File "<stdin>", line 1, in <module>  File 
"/.../lib/python3.10/site-packages/sqlalchemy/dialects/postgresql/base.py", 
line 3360, in has_schema    cursor = connection.execute(  File 
"/.../lib/python3.10/site-packages/sqlalchemy/future/engine.py", line 320, 
in _not_implemented    raise NotImplementedError(NotImplementedError: This 
method is not implemented for SQLAlchemy 2.0.*

This works if I turn off the future 
<https://docs.sqlalchemy.org/en/14/core/engines.html#sqlalchemy.create_engine.params.future>
 
flag:



*>>> engine = sqlalchemy.engine_from_config(configuration)>>> 
engine.dialect.has_schema(engine, schema)False*

Is there a fix coming? Is there an alternative suggestion? Interestingly, I 
wasn’t able to find *has_schema()* in SQLA v1.4 
<https://docs.sqlalchemy.org/en/14/core/internals.html#sqlalchemy.engine.Dialect>
 (although 
v0.7 says it was added 
<https://docs.sqlalchemy.org/en/14/search.html?q=has_schema>) but only for SQLA 
v2 
<https://docs.sqlalchemy.org/en/20/core/internals.html#sqlalchemy.engine.Dialect.has_schema>
.

For now I can use an “old” engine to check for schema, and the switch to a 
new one, but what’s the current recommendation?

Much thanks!
Jens

-- 
SQLAlchemy - 
The Python SQL Toolkit and Object Relational Mapper

http://www.sqlalchemy.org/

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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sqlalchemy/2101bd77-7dbd-4ba1-8bd1-203eadee754cn%40googlegroups.com.

Reply via email to