Commit 46aa77bb authored by Francesco Poldi's avatar Francesco Poldi

Fix `Search_name` in dbs

parent b22ca858
...@@ -91,7 +91,7 @@ def init(db): ...@@ -91,7 +91,7 @@ def init(db):
); );
""" """
cursor.execute(table_followers) cursor.execute(table_followers)
table_following = """ table_following = """
CREATE TABLE IF NOT EXISTS CREATE TABLE IF NOT EXISTS
following ( following (
...@@ -127,7 +127,7 @@ def fTable(Followers): ...@@ -127,7 +127,7 @@ def fTable(Followers):
table = "followers_names" table = "followers_names"
else: else:
table = "following_names" table = "following_names"
return table return table
def uTable(Followers): def uTable(Followers):
...@@ -135,7 +135,7 @@ def uTable(Followers): ...@@ -135,7 +135,7 @@ def uTable(Followers):
table = "followers" table = "followers"
else: else:
table = "following" table = "following"
return table return table
def follow(conn, Username, Followers, User): def follow(conn, Username, Followers, User):
...@@ -168,7 +168,7 @@ def user(conn, Username, Followers, User): ...@@ -168,7 +168,7 @@ def user(conn, Username, Followers, User):
User.media_count, User.media_count,
User.is_private, User.is_private,
User.is_verified, User.is_verified,
User.avatar, User.avatar,
date_time, date_time,
Username,) Username,)
query = 'INSERT INTO {} VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)'.format(uTable(Followers)) query = 'INSERT INTO {} VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)'.format(uTable(Followers))
...@@ -198,7 +198,7 @@ def tweets(conn, Tweet, config): ...@@ -198,7 +198,7 @@ def tweets(conn, Tweet, config):
Tweet.user_rt, Tweet.user_rt,
",".join(Tweet.mentions), ",".join(Tweet.mentions),
date_time, date_time,
config.search_name,) config.Search_name,)
cursor.execute('INSERT INTO tweets VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)', entry) cursor.execute('INSERT INTO tweets VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)', entry)
conn.commit() conn.commit()
except sqlite3.IntegrityError: except sqlite3.IntegrityError:
......
...@@ -21,7 +21,7 @@ def init(hostname,Database,db_user,db_pwd): ...@@ -21,7 +21,7 @@ def init(hostname,Database,db_user,db_pwd):
passwd=db_pwd, # your password passwd=db_pwd, # your password
db=Database,# name of the data base db=Database,# name of the data base
charset='utf8mb4', charset='utf8mb4',
use_unicode=True) use_unicode=True)
cursor = conn.cursor() cursor = conn.cursor()
#here would be the code for creating the tables if them don't exist #here would be the code for creating the tables if them don't exist
return conn return conn
...@@ -33,7 +33,7 @@ def fTable(Followers): ...@@ -33,7 +33,7 @@ def fTable(Followers):
table = "followers_names" table = "followers_names"
else: else:
table = "following_names" table = "following_names"
return table return table
def uTable(Followers): def uTable(Followers):
...@@ -41,7 +41,7 @@ def uTable(Followers): ...@@ -41,7 +41,7 @@ def uTable(Followers):
table = "followers" table = "followers"
else: else:
table = "following" table = "following"
return table return table
def follow(conn, Username, Followers, User): def follow(conn, Username, Followers, User):
...@@ -74,16 +74,16 @@ def user(conn, Username, Followers, User): ...@@ -74,16 +74,16 @@ def user(conn, Username, Followers, User):
User.media_count, User.media_count,
User.is_private, User.is_private,
User.is_verified, User.is_verified,
User.avatar, User.avatar,
date_time, date_time,
Username,) Username,)
query = 'INSERT INTO {} VALUES(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)'.format(uTable(Followers)) query = 'INSERT INTO {} VALUES(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)'.format(uTable(Followers))
cursor.execute(query, entry) cursor.execute(query, entry)
conn.commit() conn.commit()
except MySQLdb.IntegrityError: except MySQLdb.IntegrityError:
pass pass
def tweets(conn, Tweet, config): def tweets(conn, Tweet, config):
try: try:
...@@ -106,7 +106,7 @@ def tweets(conn, Tweet, config): ...@@ -106,7 +106,7 @@ def tweets(conn, Tweet, config):
Tweet.user_rt, Tweet.user_rt,
",".join(Tweet.mentions), ",".join(Tweet.mentions),
date_time, date_time,
config.search_name,) config.Search_name,)
cursor.execute('INSERT INTO tweets VALUES(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)', entry) cursor.execute('INSERT INTO tweets VALUES(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)', entry)
conn.commit() conn.commit()
except MySQLdb.IntegrityError: except MySQLdb.IntegrityError:
......
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