我想将python字典作为json插入我的postgresql数据库(通过python和psycopg2).
我有:
thedictionary = {'price money': '$1', 'name': 'Google', 'color': '', 'imgurl': 'http://www.google.com/images/nav_logo225.png', 'charateristics': 'No Description', 'store': 'google'}
cur.execute("INSERT INTO product(store_id, url, price, charecteristics, color, dimensions) VALUES (%d, %s, %s, %d, %s, %s)", (1, 'http://www.google.com', '$20', thedictionary, 'red', '8.5x11'))
它给出了错误信息:
cur.执行("插入产品(store 标识、url、价格、特征、 colored颜色 、尺寸)值(%d、%s、%s、%d、%s、%s)",(1,'http://www.google.com','20',插图,'red','8.5x11'))
我不知道如何从这里开始.