Insert into oracle table from CSV using python
<p>I am reading a csv file with 5 columns and push to oracle table</p>

<p><a href="http://i.stack.imgur.com/kkoNu.jpg" rel="nofollow">CSV file Structure</a></p>

<p>I know there are lots of resources on this .. But even then I am unable to find a solution for my problem </p>

<p>Code to read the CSV to python : </p>

<pre><code> import csv
 reader = csv.reader(open("sample.csv","r"))
 lines=[]
 for line in reader:
      lines.append(line)
  print lines 
</code></pre>

<p>Output :</p>

<blockquote>
  <p>[['Firstname', 'LastName', 'email', 'Course_name', 'status'],
  ['Kristina', 'Bohn', 'abc@123.com', 'Guide to
  Capnography in the Management of the Critically Ill Patient (CE)',
  'Registered'], ['Peggy', 'Lutz', 'gef@123.com',
  'Guide to Monitoring EtCO2 During Opioid Delivery (CE)', 'In
  Progress']]</p>
</blockquote>

<p>Code to push the list to Oracle table :</p>

<pre><code>import cx_Oracle
con = cx_Oracle.connect('username/password@tamans*****vd/Servicename')
ver=con.version.split(".")
print(ver)
cur=con.cursor()
cur.execute("INSERT INTO TEST_CSODUPLOAD ('FIRSTNAME','LASTNAME','EMAIL','COURSE_NAME','STATUS') VALUES(:1,:2,:3,:4,:5)",lines)
con.commit ()
cur.close()
</code></pre>

<p>I am getting the error :</p>

<p><strong>DatabaseError: ORA-01484: arrays can only be bound to PL/SQL statements</strong></p>

<p>Please help me solve the issue Thanks in advance </p>

<p>That error means what it said <a href="https://bitbucket.org/anthony_tuininga/cx_oracle/issues/36/ora-01484-arrays-can-only-be-bound-to-pl" rel="nofollow">here</a> </p>

<blockquote>
  <p>This is not a bug. You are issuing a SQL query, not a PL/SQL statement and this sort of thing is not supported by Oracle. In this particular case you can simply pass the string. If you have multiple strings you will need to use a subquery instead. Look at the table() and cast() operators for inspiration!</p>
</blockquote>

<p>You can also dump into a sql file and execute it. </p>

python oracle csv insert-into cx-oracle