Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using sqlalchemy.ext.compiler with BINDS #125

Closed
jawsthegame opened this issue Apr 10, 2013 · 2 comments
Closed

Using sqlalchemy.ext.compiler with BINDS #125

jawsthegame opened this issue Apr 10, 2013 · 2 comments

Comments

@jawsthegame
Copy link

When using the compiles decorator as in this example:

http://docs.sqlalchemy.org/en/rel_0_8/core/compiler.html#compiling-sub-elements-of-a-custom-expression-construct

Queries constructed in this way do not seem to obey the bind_key in the info dictionary on the table.

In this code, I have added some debugging:

@compiler.compiles(InsertFromSelect)
   def visit_insert_from_select(element, compiler, **kwargs):
       print element.table.info
       return 'INSERT INTO %s %s' % (
           compiler.process(element.table, asfrom=True),
           compiler.process(element.select))

That info dictionary has the following value:

{"bind_key": "reporting"}

Which is the correct bind key. However, it is still attempting to query the default database specified in SQLALCHEMY_DATABASE_URI.

When I do a simple select('*', from_obj=[MY_TABLE]) this works as expected. It seems to be lost on the compiled stuff.

Any thoughts?

@kblomqvist
Copy link

May be related to #222.

@rsyring rsyring added this to the 3.x milestone Mar 9, 2019
@davidism
Copy link
Member

davidism commented Sep 18, 2022

Assuming this is about metadata per bind, this would be fixed by #1087. Given the age, I'm going to close this, please reopen with a reproducible example if it's still an issue after that PR.

@davidism davidism removed this from the 3.x milestone Sep 18, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 3, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

4 participants