0

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.
Paco
  • 4,520
  • 3
  • 29
  • 53
Abhishek Dujari
  • 2,343
  • 33
  • 43

1 Answers1

1

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()
plaes
  • 31,788
  • 11
  • 91
  • 89
  • that kind of sucks because there is a whole bunch of other properties. I ditched elixir because it seems only way is to write a wrapper or something. If you can help with my other query I won't need to solve this. I accept it as a right answer ofcourse since it will kind of solve the problem. thanks. – Abhishek Dujari Feb 27 '12 at 16:55
  • when using `declarative` syntax, this property is usually set to `declarative_base(...)` returned class, which is the base class for all the models, and as such all models will have the `query` property. And if you do not use `declarative`, still nothing prevents you from setting this property to some common base class. – van Feb 27 '12 at 21:03