I am trying to insert to multiple tables, but have them share only one timestamp. I am implementing something like this:
for table in table_names:
current_utc_time = str(datetime.utcnow())
cursor.execute("INSERT INTO public.{0} VALUES({1}, {2})".format(table, current_utc_time, foo))
But this set of code throws me the following error...
Traceback (most recent call last):
File "C:/Users/EricKim/Documents/sage/fake_data_push.py", line 58, in <module>
cursor.execute("INSERT INTO public.{0} VALUES({1}, {2})".format(table, current_utc_time, df.iloc[row_num, col_num]))
psycopg2.ProgrammingError: syntax error at or near "16"
LINE 1: INSERT INTO public.rt_torqx VALUES(2018-08-30 16:26:35.20088...
There must be some formatting error, but I do now know what's wrong, because to my understanding 2018-08-30 16:26:35.20088 is the right format of pgsql timestamp string format. Can anyone tell me what's wrong?