title: Import data from Excel into Oracle Table using Python
body: <p>Peers,</p>
  
  <p>Newbie here. Is there a way we can read data from excel file and load into Oracle table? Some sample python script would be of great help. I did code few lines to get acquainted as shown below.</p>
  
  <p>P.S. Edit: I mean this is just my partial code. I am not sure how can I have 'insert statement' or 'create table' statement as part of this code in Oracle part. I want to load the data as it reads from excel in a loop for every column. TIA!</p>
  
  <pre><code>import openpyxl
  import cx_Oracle
  
  #Oracle connection starts here
  connection = cx_Oracle.connect("&lt;schema&gt;", "&lt;pwd&gt;", "&lt;hostname&gt;/&lt;sid/service&gt;")
  print("Database version:", connection.version)
  print(cx_Oracle.version)
  print(connection.current_schema)
  
  # creating a table
  create_table = """
  CREATE TABLE test (
  col1 VARCHAR2(50) NOT NULL,
  col2 VARCHAR2(50) NOT NULL,
  col3 VARCHAR2(50) NOT NULL,
  col4 VARCHAR2(50) NOT NULL,
  col5 VARCHAR2(50) NOT NULL,
  col6 VARCHAR2(50) NOT NULL,
  col7 VARCHAR2(50) NOT NULL
  )
  """
  from sys import modules
  cursor.execute(create_table)    
  
  from openpyxl import Workbook
  wb = openpyxl.load_workbook('&lt;name of the file&gt;',data_only=True)
  ws = wb['Sheet1']
  
  x=1
  m=1
  
  # looping through each column
  for j in range(2,ws.max_column+1):
  
     ID = m 
     col1 = ws.cell(row=x,column=j).value  
     m = m+1
  
     col2 = ws.cell(row=1, column=j).value
  
     col3 = ws.cell(row=2, column=j).value
  
     col4 = ws.cell(row=3,column=j).value
  
     col5 = ws.cell(row=4, column=j).value
  
     col6 = ws.cell(row=5, column=j).value
  
     col7 = ws.cell(row=6, column=j).value
  
     #looping through each row for each column      
     for i in range(1,ws.max_row+1):
           Cellval= ws.cell(row=i, column=j).value
  
  # Inserting all the above variables for each column loop
  insert_table="""
  INSERT INTO test (col1,col2,col3,col4,col5,col6,col7)
  VALUES ("""+col1+""",
  """+col2+""",
  """+col3+""",
  """+col4+""",
  """+col5+""",
  """+col6+""",
  """+col7+""")"""
  
  cursor.execute(insert_table)
  
  x=x+1
  
  connection.close()
  </code></pre>
  
  <p>Am I getting it right?</p>