Home > Back-end >  How to create peewee database at custom path
How to create peewee database at custom path

Time:06-15

I'm trying to create a database at a certain path, but I cannot figure out how to do so because I need to reference the created database in the Meta

I'm trying to create the database something like this:

class Domain(Model):
    ...

    class Meta:
        database = db

...

def create_database(path: str, start_block: int):
    db = SqliteDatabase(os.path.join(path, "db"))

    db.create_tables([Domain, Event, State])

    if State.select().count() == 0:
        State.create(height=start_block)

CodePudding user response:

This is covered in the documentation:

  • Related