I want to insert 185 columns consisting of 7L rows from a CSV file in to a Oracle Sql table using Python. I have used Cx_oracle to connect to Oracle DB. I know how to insert data in to table using python for small sets of data (having around 10 to 20 columns), but want to know how to do it for large sets(185 columns). Here is my sample code:
connection=cx_Oracle.connect("dbUrl",encoding="UTF-8")
cur = connection.cursor()
print("connected to DB")
if csv_file.startswith('Co_'):
with open(csv_file, "r") as csv_file:
csv_reader = csv.reader(csv_file, delimiter=',')
next(csv_reader)
for lines in csv_reader:
cur.execute(
"insert into company_details(company_id,product_id,product_first_date,product_last_date,product_year,product_total,product_volume) values (:1, :2, TO_DATE( :3,'YYYY-MM-DD'),TO_DATE( :4,'YYYY-MM-DD'), :5, :6, :7)",
(lines[0], lines[1], lines[2], lines[3], lines[4], lines[5], lines[6]))
print("data loaded")
else:
print("diff file")
sftp.close()
Can somebody help me out on how to insert this huge data in to Oracle table using python?