How to insert DEFAULT value, please?

import psycopg2
from psycopg2.sql import DEFAULT        # 
https://www.postgresql-archive.org/Inserting-default-values-into-execute-values-td6130148.html

db = psycopg2.connect(host='host', dbname='db')
cursor = db.cursor()
cursor.execute("DROP TABLE IF EXISTS test_default")
cursor.execute("CREATE TABLE test_default(i int NOT NULL DEFAULT 1)")
cursor.execute("INSERT INTO test_default VALUES (%s)", (DEFAULT,))

cursor.execute("DROP TABLE IF EXISTS test_default")
cursor.execute("CREATE TABLE test_default(j jsonb NOT NULL DEFAULT 
'{}'::jsonb)")
cursor.execute("INSERT INTO test_default VALUES (%s)", (DEFAULT,))

For both cases I get
psycopg2.ProgrammingError: can't adapt type 'SQL'

Thank you in advance,
HG


Reply via email to