Advertisement
Guest User

Untitled

a guest
Mar 14th, 2016
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. import datetime
  2. import psycopg2
  3. import export
  4. import globals
  5.  
  6.  
  7. def construct_new_day(db, cursor):
  8. print("constructing")
  9. yesterday = globals.db_meta_table, datetime.date.today() - datetime.timedelta(days=-1)
  10. cursor.execute("SELECT * FROM (%s) WHERE date=(%s)", (yesterday,))
  11. pass
  12.  
  13. def main():
  14. time = datetime.datetime.now()
  15. date = datetime.date.today()
  16.  
  17. print(date)
  18.  
  19. try:
  20. db = psycopg2.connect("dbname=" + globals.db_name + " user=" + globals.db_user +
  21. " host=" + globals.db_ip + " password=" + globals.db_pass)
  22. db_cursor = db.cursor()
  23. db.commit()
  24. except psycopg2.OperationalError:
  25. print("Failed to connect to database")
  26. return
  27.  
  28. db_cursor.execute("SELECT * FROM (%s) WHERE date=(%s);", (globals.db_meta_table, date))
  29.  
  30. print(db_cursor.fetchall())
  31.  
  32. if db_cursor.fetchall() == []:
  33. construct_new_day(db, db_cursor)
  34.  
  35.  
  36. export.main(db, db_cursor)
  37.  
  38. if __name__ == "__main__":
  39. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement