Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Error using Cx_Oracle
#1
Hello,

I am kinda new to python and i need help with my code.
I am trying to use cx_Oracle to insert my data from a flat file into my oracle database table (oracle 12c).
After reading my data using pandas and looping over it, I get the error " DatabaseError: ORA-01008: not all variables bound" when trying to insert.

I need urgent help resolving this.

Here is the portion of my code having the error:

for key, value in indvdl.sample(4 , replace=True).iterrows():
    print (type( value))
    for x in value.to_dict().items():
        sql = """INSERT INTO individuals (CUSTOMER_ID, BRANCH_CODE, Surname, FIRST_NAME, MIDDLE_NAME, Date_of_Birth, National_Identity_Number, Drivers_License_No, BVN, Passport, Gender, Nationality, Marital_Status, Mobile_number, Primary_Address_Line_1, Primary_Address_Line2, Primary_city, Primary_State, Primary_Country, Employment_Status, Occupation, Business_Category, Business_Sector, Borrower_Type, Other_ID, Tax_ID, Picture_File_Path, Email, Employer_Name, Employer_Address_Line1, Employer_Address_Line2, Employer_City, Employer_State, Employer_Country, Title, Place_of_Birth, Work_phone, Home_phone, Sec_Address_Line1, Sec_Address_Line2, Sec_Address_City, Sec_Address_State, Sec_Address_Country, Spouses_Surname, Spouses_firstname, Spouses_Middlename, CYCLE_VER, DPID) 
VALUES (:1,:2,:3,:4,:5,:6,:7,:8,:9,:10,:11,:12,:13,:14,:15,:16,:17,:18,:19,:20,:21,:22,:23,:24,:25,:26,:27,:28,:29,:30,:31,:32,:33,:34,:35,:36,:37,:38,:39,:40,:41,:42,:43,:44,:45,:46,:47,:48)"""

cursor.execute(sql, tuple(x))
Reply
#2
Have you checked that there are as many items in x as are expected in the query?
Reply
#3
And also: "cursor.execute()" should be indented just as "sql = ...".
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020