SQL = "INSERT INTO authors (name) VALUES (%s);" # Note: no quotes
data = ("O'Reilly", )
cur.execute(SQL, data) # Note: no % operator
이거 테이블 문자열이라고 뱉아냄
sql.SQL("SELECT * FROM {} WHERE scene_name = %s").format(sql.Identifier(settings.TABLE_NAMES.get('scene_table'))),
>>>
psycopg2.errors.UndefinedTable: relation "data_platform.tbl_sia_scenes" does not exist
LINE 1: UPDATE "data_platform.tbl_sia_scenes" as a SET sensor_id = b...
^
args_str = ','.join(cur.mogrify("(%s,%s,%s,%s,%s,%s,%s,%s,%s)", x) for x in tup)
cur.execute("INSERT INTO table VALUES " + args_str)
def insert_sample_data(self, values): # added self since you are referencing it below
with self.con.cursor() as cur:
sql = "insert into sampletable values (%s, %s, %s)" # Use %s for parameters
cur.executemany(sql, values) # Pass the list of tuples directly
self.con.commit()
list1 = [(1100, 'abc', '{"1209": "Y", "1210": "Y"}'), (1100, 'abc', None)]
self.insert_sample_data(list1) # pass the list directly