Abhishek Dujari
Abhishek Dujari

Reputation: 2443

Using Flask with Elixir and SQL alchemy

I am trying to use Elixir with Flask. Reason being using SQL Alchemy directly has me confused about the data insert on Many to Many relations. So I have created the models file and generated the tables I need.

For SQl alchemy I call from flask like this:

db = SQLAlchemy(app)

How to do same for Elixir? I have a model method for get_or_init on Entity so I am trying to use that as well.

When I try to use SQLAlchemy itself (since elixir is just wrapper) I get:

AttributeError: type object 'User' has no attribute 'query' where User is a model.

Upvotes: 0

Views: 1179

Answers (1)

plaes
plaes

Reputation: 32716

Although I haven't used Elixir myself, the issue with missing query is simple - you need to add the query property to the models yourself:

class User(object):
    query = Session.query_property()

Upvotes: 1

Related Questions