Python Peewee不';不要创建数据库
Python 3.6。我正在通过一些教程学习如何使用peewee。使用下面的代码,我应该能够在脚本所在的文件夹中看到'students.db',但是当我运行代码时,没有出现错误,但是我没有看到在该文件夹中创建的任何数据库。有什么想法吗?谢谢Python Peewee不';不要创建数据库,python,database,python-3.x,peewee,Python,Database,Python 3.x,Peewee,Python 3.6。我正在通过一些教程学习如何使用peewee。使用下面的代码,我应该能够在脚本所在的文件夹中看到'students.db',但是当我运行代码时,没有出现错误,但是我没有看到在该文件夹中创建的任何数据库。有什么想法吗?谢谢 import peewee as pw db = pw.SqliteDatabase('students.db') class Student(pw.Model): username = pw.CharField(max_length=255,
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)
将main更改为
\uuuu main\uuuu
if __name__ == '__main__':
db.connect()
db.create_tables([Student], safe=True)