Commit 5c4e897e authored by Francesco Poldi's avatar Francesco Poldi

Added tables for followers and following

parent ff66050b
...@@ -86,6 +86,26 @@ def initdb(db): ...@@ -86,6 +86,26 @@ def initdb(db):
); );
""" """
cursor.execute(table_search) cursor.execute(table_search)
table_followers = """
CREATE TABLE IF NOT EXISTS
followers (
user text not null,
date_update text not null,
follower text not null,
PRIMARY KEY (user, follower)
);
"""
cursor.execute(table_followers)
table_following = """
CREATE TABLE IF NOT EXISTS
following (
user text not null,
date_update text not null,
follows text not null,
PRIMARY KEY (user, follows)
);
"""
cursor.execute(table_following)
return conn return conn
except Exception as e: except Exception as e:
return str(e) return str(e)
...@@ -543,6 +563,19 @@ async def outFollow(f): ...@@ -543,6 +563,19 @@ async def outFollow(f):
output = user output = user
if arg.database:
try:
date_time = str(datetime.datetime.now())
cursor = conn.cursor()
entry = (arg.u, date_time, user,)
if arg.followers:
cursor.execute('INSERT INTO followers VALUES(?,?,?)', entry)
else:
cursor.execute('INSERT INTO following VALUES(?,?,?)', entry)
conn.commit()
except sqlite3.IntegrityError: # this happens if the entry is already in the db
pass
if arg.o != None: if arg.o != None:
print(output, file=open(arg.o, "a", encoding="utf-8")) print(output, file=open(arg.o, "a", encoding="utf-8"))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment