Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import datetime
- import psycopg2
- import export
- import globals
- def construct_new_day(db, cursor):
- print("constructing")
- yesterday = globals.db_meta_table, datetime.date.today() - datetime.timedelta(days=-1)
- cursor.execute("SELECT * FROM (%s) WHERE date=(%s)", (yesterday,))
- pass
- def main():
- time = datetime.datetime.now()
- date = datetime.date.today()
- print(date)
- try:
- db = psycopg2.connect("dbname=" + globals.db_name + " user=" + globals.db_user +
- " host=" + globals.db_ip + " password=" + globals.db_pass)
- db_cursor = db.cursor()
- db.commit()
- except psycopg2.OperationalError:
- print("Failed to connect to database")
- return
- db_cursor.execute("SELECT * FROM (%s) WHERE date=(%s);", (globals.db_meta_table, date))
- print(db_cursor.fetchall())
- if db_cursor.fetchall() == []:
- construct_new_day(db, db_cursor)
- export.main(db, db_cursor)
- if __name__ == "__main__":
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement