简体   繁体   中英

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)

Change main to __main__ ;

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM