3
我想用字典光標在psycopg2
:psycopg2.ProgrammingError:無法適應型 'DictRow'
self.__db_conn = psycopg2.extras.DictConnection("host=... dbname=...")
這裏是我的查詢:
cur.execute('INSERT INTO scm_main.tbl_ack(ack_summary_id, ack_local_timestamp, ack_user_id) '
'SELECT summary_id AS ack_summary_id, now() AS ack_local_timestamp, us.user_id AS ack_user_id '
'FROM scm_main.tbl_summary AS s '
'INNER JOIN scm_main.vu_usr_stn AS us ON (s.summary_station_id = us.station_axis_id) '
'WHERE ((s.summary_id > (SELECT COALESCE(max(a.ack_summary_id),0) FROM scm_main.tbl_ack AS a WHERE a.ack_user_id = %(user_id)s)) '
'AND (s.summary_company_specific_id <> 0) '
'AND (us.user_name = %(user_name)s) AND (s.summary_timestamp < (now() - \'00:25:00\'::interval))) '
'ORDER BY s.summary_id ASC', { 'user_id': self.__user_id, 'user_name': self.__company })
但它給我:
<class 'psycopg2.ProgrammingError'> exception: can't adapt type 'DictRow'
任何人都可以幫忙嗎?
當這種情況發生時,您能否顯示'self .__ user_id'和'self .__ company'的類型和值?很可能其中之一是「DictRow」。 –