mise a jour

This commit is contained in:
Abdel-Kader Chabi-Sika-Boni 2020-12-22 01:02:48 +01:00
父節點 42cefc2a81
當前提交 d375b6fd08
共有 2 個文件被更改,包括 23 次插入2 次删除

二進制
files.db

Binary file not shown.

查看文件

@ -4,7 +4,7 @@ from datetime import datetime
def create_table_files():
conn = sqlite3.connect("files.db", detect_types=sqlite3.PARSE_DECLTYPES | sqlite3.PARSE_COLNAMES)
cur = conn.cursor()
cur.execute("CREATE TABLE files (name VARCHAR(255) PRIMARY KEY, moment DATETIME, length INT);")
cur.execute("CREATE TABLE files (name VARCHAR(255) PRIMARY KEY, moment TIMESTAMP, length INT);")
conn.commit()
conn.close()
@ -47,7 +47,28 @@ def query_from_table_files(number=30):
for row in rows:
print(row)
def query_from_table_files_with_moment(moment=datetime(2020,11,21,15,23,0,0)):
conn = sqlite3.connect("files.db", detect_types=sqlite3.PARSE_DECLTYPES | sqlite3.PARSE_COLNAMES)
cur = conn.cursor()
cur.execute("SELECT * FROM files;")
rows = cur.fetchall()
conn.close()
for row in rows:
if row[1] >= moment:
print(row)
def drop_table_files():
conn = sqlite3.connect("files.db", detect_types=sqlite3.PARSE_DECLTYPES | sqlite3.PARSE_COLNAMES)
cur = conn.cursor()
cur.execute("DROP TABLE files;")
conn.commit()
conn.close()
# create_table_files()
# drop_table_files()
# populate_table_files()
# unpopulate_table_files()
query_from_table_files()
# query_from_table_files()
query_from_table_files_with_moment()