26 lines
617 B
Python
26 lines
617 B
Python
|
|
import mysql.connector as mariadb
|
||
|
|
import dateparser, logging
|
||
|
|
import db.sql, db.utils
|
||
|
|
|
||
|
|
|
||
|
|
def query_url(db_con, date_str, from_str, table_str):
|
||
|
|
|
||
|
|
d = db.utils.format_date(date_str)
|
||
|
|
auth = db.utils.format_author(from_str)
|
||
|
|
|
||
|
|
try:
|
||
|
|
result = []
|
||
|
|
cursor = db_con.cursor(buffered=True)
|
||
|
|
cursor.execute(db.sql.URL_QUERY.format(table_str, auth, d))
|
||
|
|
for u in cursor:
|
||
|
|
result.append(u[0])
|
||
|
|
return result
|
||
|
|
except mariadb.Error as error:
|
||
|
|
logging.error("Mariadb error - query_url")
|
||
|
|
logging.error(error)
|
||
|
|
return None
|
||
|
|
except Exception as e:
|
||
|
|
logging.error("Error - query_url")
|
||
|
|
return None
|
||
|
|
finally:
|
||
|
|
cursor.close()
|