BigP
BigP

Reputation: 109

How to create peewee database at custom path

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)

Upvotes: 0

Views: 416

Answers (1)

Related Questions