mise a jour
This commit is contained in:
parent
42cefc2a81
commit
d375b6fd08
2 changed files with 23 additions and 2 deletions
BIN
files.db
BIN
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()
|
Loading…
Reference in a new issue