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

ORM Support? #4

Open
fgblomqvist opened this issue Apr 13, 2018 · 3 comments
Open

ORM Support? #4

fgblomqvist opened this issue Apr 13, 2018 · 3 comments

Comments

@fgblomqvist
Copy link

I'm confused as to if this adds view support to the SQLAlchemy ORM?
As in, how would I go about defining a view model with this (that would be created/dropped automatically when the create_all/drop_all commands are used)?

Ideally one would be able to do something like:

class MyView(ModelView):
    definition = 'SELECT * FROM mytable'
    # column declaration that reflects the SQL

But I'm not sure if this addon allows for anything remotely like that.

@fgblomqvist
Copy link
Author

Was looking at an old recipe (https://bitbucket.org/zzzeek/sqlalchemy/wiki/UsageRecipes/Views) but it's using the deprecated execute_at. Tried replicating it using the new DDL events, which went alright I think, however, it still (obviously) emits the normal create and drop statements. Which means it's creating a table, then tries to create a view. Maybe we're supposed to override the create and drop functions instead?

@jklukas
Copy link
Owner

jklukas commented Apr 16, 2018

I haven't personally used the ORM much, so the use cases there aren't immediately obvious to me. I'll try to take more of a look at your suggestions later this week.

@fgblomqvist
Copy link
Author

No worries. After a ton of researching and experimenting, I successfully came up with a solution that works (so far): https://stackoverflow.com/a/49894177/998919.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants