1import psycopg2
2
3conn = psycopg2.connect(host=pg_credential.hostname,
4 port=pg_credential.port,
5 user=pg_credential.username,
6 password=pg_credential.password,
7 database=pg_credential.path[1:]) # To remove slash
8
9cursor = conn.cursor()
10cursor.execute("INSERT INTO a_table (c1, c2, c3) VALUES(%s, %s, %s)", (v1, v2, v3))
11conn.commit() # <- We MUST commit to reflect the inserted data
12cursor.close()
13conn.close()
14