dededdew
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
from peewee import *
|
||||
|
||||
# 连接到 SQLite 数据库,如果文件不存在会自动创建
|
||||
db = SqliteDatabase('database.db')
|
||||
db = SqliteDatabase(r'C:\Users\27942\Desktop\job\models\database.db')
|
||||
|
||||
Binary file not shown.
@@ -14,20 +14,9 @@ class Weex(Model):
|
||||
database = db
|
||||
table_name = 'weex'
|
||||
|
||||
|
||||
# 连接到数据库
|
||||
db.connect()
|
||||
|
||||
# 创建表(如果表不存在)
|
||||
db.create_tables([Weex])
|
||||
|
||||
# 示例数据
|
||||
data = ['100', '101', '99', '100.5', 1]
|
||||
|
||||
# 使用 get_or_create 方法插入数据
|
||||
Weex.get_or_create(
|
||||
id=data[1],
|
||||
open=data[0],
|
||||
high=data[1],
|
||||
low=data[2],
|
||||
close=data[3]
|
||||
)
|
||||
Reference in New Issue
Block a user