函数和参数我搞不清楚(请告诉我,不要扔拖鞋
def get_connect_to_database():
try:
connect = psycopg2.connect(dbname = name_of_database, user = user, password = password, host= host)
print('\n', Fore.GREEN+'================= CONNECTION OK =================')
print(Fore.RESET)
cur = connect.cursor()
time_start = time.time()
except Exception as _ex:
print(Fore.RED + '[-Error-]CONNECTION NOT OK', _ex)
def get_query_from_database():
try:
get_data_from_first_table = """
SELECT id,pas_id, date_add, status_id
FROM status_history
where status_id !=7
and date_add>= now()- interval '10 day'
order by date_add desc limit 50"""
cur.execute(get_data_from_first_table)
data_frame_from_first_table = cur.fetchall()
print(get_data_from_first_table)
except Exception as _ex:
print(Fore.RED + "[-Error-] ERROR WITH QUERY")
如何将cur
正确的功能添加到def get_query_from_database()
. 他不活跃
有几种选择: