当变量在 Python 中时,是否有向 PostgreSQL 数据库输入NULL
键值的好习惯?None
运行此查询:
mycursor.execute('INSERT INTO products (user_id, city_id, product_id, quantity, price) VALUES (%i, %i, %i, %i, %f)' %(user_id, city_id, product_id, quantity, price))
当is时导致TypeError
异常。user_id
None
当值为 时,如何使用驱动程序将 aNULL
插入数据库?None
psycopg2