DataBase is already created(PostgreSQL)
There is a list:
data =
['param_1', 0],
['amp', 0],
['voltage', 1],
['params', 1],
['antenna', 1],
['freq', 0.00011000000085914508]
I tried that
import psycopg2
from psycopg2 import sql
with psycopg2.connect(dbname='db_name', user='postgres',
password='123', host='localhost') as conn:
conn.autocommit = True
with conn.cursor() as cur:
query = "INSERT INTO table_name (%s) VALUES (%s);"
cur.executemany(query, data)
I need to insert values in the table in the database that contains fields named: 'param_1': 'paRam_2' e.t.c.
How do I generate a query string?
I will be happy for any help, thanks in advance, stack.