-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdb.py
More file actions
31 lines (26 loc) · 678 Bytes
/
Copy pathdb.py
File metadata and controls
31 lines (26 loc) · 678 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# Module python for Db operation
import sqlite3 as sql
# function to return the name of all the files saved in the db
def view():
con = sql.connect("database.db")
cur = con.cursor()
cur.execute("select * from files")
files = cur.fetchall()
print (files)
con.close()
return files
def delete(name):
con = sql.connect("database.db")
cur = con.cursor()
cur.execute("DELETE FROM files WHERE name='" + name + "'")
con.commit()
con.close()
def insert(name):
con = sql.connect("database.db")
cur = con.cursor()
try:
cur.execute('DELETE FROM files WHERE name="'+name+'"')
except:
pass
cur.execute("insert into files(name) values ('"+ name + "')")
con.commit()