Selecting databases in Meta is very non-flexible
Thanks for bringing this up - the need to have a database instance at model definition time is ... well, it is what it is.  You brought up django -- django declares the database(s) in a global (and much maligned) settings object.  One of the decisions I made with peewee was to make it _not_ need global database configuration.  One question is, if you don't declare your database at class creation time, what time _is_ appropriate?

I'm not sure if this will help you, but my general workflow looks like this (to avoid circular imports):
- app.py
  - flask application instantiation
  - peewee database instantiation
  - create a "BaseModel" class that uses the above database
- models.py or whatever
  - import the BaseModel from app.py and extend for any specific models I need
- views.py
  - import the flask app from app.py to create blueprint/url rules/etc
  - import any models needed from app.py
- main.py
  - import the flask app from app.py
  - import all the views so they get registered
  - run the flask app or whatever
 I think that database selection should be be able to take place any time before a connection needs to be made, so in the case of flask, sometime before @app.before_request ideally. For example, instead of the model classes holding a pointer to a database object, they hold a pointer to a callable that will give them a database object when they're instantiated. Or, both are permitted so the simple case doesn't change.

I understand that there are reasonable ways to do everything in the global scope - and maybe that's the pythonic way - but it seemed weird when I had to move a lot of my stuff from classes into toplevel code to get it working.
 Cool, also bear in mind that there's a difference between the database object (what you use with models) and the underlying connection/when that connection is made.  It is made when it is first needed if not explicitly created.  Also, you may want to check out flask-peewee, which does some of the things you've mentioned.

https://github.com/coleifer/flask-peewee/tree/master/example

I don't know Django very well, but as far as I could tell, Django doesn't use the Meta class in models to select the database to use, and probably for a good reason?

I really like peewee, but I had to restructure some of my base application flow because all Peewee model classes have to have the database instance available immediately on class creation and in some global scope. The examples of course look fine, but for an application like mine that is larger and uses blueprints and all that, the Meta/inheritance system was a bit awkward to use.

do you think there's a way to just have a global bind variable? Like Elixir:

```
 elixir.metadata.bind = "sqlite:///db.sqlite"
```

Put simply, it would be nice to have a way to set the database object after the Model classes have been created.
