TmSmth
TmSmth

Reputation: 452

Peewee doesn't create database

Python 3.6. I'm learning how to use peewee through some tutorials. With the code below i should be able to see 'students.db' in the folder where my script is, but when i run the code, there is no error but i don't see any database created in the folder. any ideas ? Thanks !

import peewee as pw

db = pw.SqliteDatabase('students.db')

class Student(pw.Model):
    username = pw.CharField(max_length=255, unique=True)
    points = pw.IntegerField(default=0)

    class Meta:
        database = db

if __name__ == 'main':
    db.connect()
    db.create_tables([Student], safe=True)

Upvotes: 0

Views: 407

Answers (1)

Tom
Tom

Reputation: 725

Change main to __main__;

if __name__ == '__main__':
    db.connect()
    db.create_tables([Student], safe=True)

Upvotes: 1

Related Questions