I am trying to insert a dictionary into an Oracle table and its failing with data mismatch error. I want to know if the syntax I am using is a correct one.
In [19]:selrow
Out[19]:[{'CUSTOMER_NM': 'ABC INC',
'CUSTOMER_NO': 'A0050129',
'CUSTOMER_SK': 926,
'EFFECTIVE_DT': datetime.datetime(2015, 10, 2, 0, 0)}]
Here is my insert statement:
In [30]:cur=db.cursor()
cur.execute('INSERT INTO DIM_CUST (%s) VALUES (%s)', (selrow[0].keys(), selrow[0].values()))
db.commit()
and I am getting the following error:
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-30-eefac6fb0aa7> in <module>()
2 #query = 'INSERT INTO DIM_CUST (%s) VALUES (%s)', (selrow[0].keys(), selrow[0].values())
3 #rint query
----> 4 cur.execute('INSERT INTO DIM_CUST (%s) VALUES (%s)', (selrow[0].keys(), selrow[0].values()))
5 db.commit()
TypeError: expecting numeric data
Is my insert syntax correct? I am using dictionary keys as column names and dictionary values as the values to be entered into the table.
pl. ask any details i may have omitted. Thank you for any help that you can provide.