0

I have a flask app that's using flask_peewee.db in it's app module:

from flask_peewee.db import Database

Is it possible to replace the flask_peewee Database module with a plain peewee module? The author of flask_peewee says it's in maintenance mode and while not exactly sunset, I'm reluctant to start a new project using it. Unfortunately, I love the flask/peewee combo and it appears flask_peewee may be the only way to bind the two together without heartache. Ideas?

David Watson
  • 3,394
  • 2
  • 36
  • 51

1 Answers1

0

You can try out the FlaskDB object in playhouse.flask_utils:

http://docs.peewee-orm.com/en/latest/peewee/playhouse.html#database-wrapper

While not 100% the same, I think that might work well for you.

coleifer
  • 24,887
  • 6
  • 60
  • 75
  • Thanks, Charles. I tried your suggestion with CPython 2.7, pypy 2.7, and CPython 3.5. The 2.7 variants yield http://stackoverflow.com/questions/11276037/python-3-typeerror-metaclass-conflict-the-metaclass-of-a-derived-class-must-b on the model classes. The 3.5 variant yields this error on the UserRoles m2m link table: http://stackoverflow.com/questions/2464568/can-someone-explain-what-exactly-this-error-means-typeerror-issubclass-arg-1 I tried various suggestions of working around those errors but none worked. – David Watson Dec 18 '15 at 02:18
  • I figured it out. I was passing FlaskDB.Model as the base class of the models instead of the db instance model. Thank you! – David Watson Dec 18 '15 at 03:11