title: How to write pandas dataframe to oracle database using to_sql?
body: <p>I'm a new oracle learner. I'm trying to write a pandas dataframe into an oracle table. After I have made research online, I found the code itself is very simple, but I don't know why my code doesn't work.</p>
  
  <p>I have read the pandas dataframe from my local file:</p>
  
  <pre><code>import cx_Oracle
  import pandas as pd
  import os
  
  dir_path = os.path.dirname(os.path.realpath("__file__"))
  df = pd.read_csv(dir_path+"/sample.csv")
  </code></pre>
  
  <p>Now print df, the dataframe df shold be like this:</p>
  
  <pre><code>   DATE            YEAR     MONTH      SOURCE      DESTINATION
  0  11/1/2017 1:00  2017     1          AL          CO  
  1  11/2/2017 1:00  2017     5          GA          ID  
  2  11/3/2017 1:00  2017     12         GA          MO    
  </code></pre>
  
  <p>Then I create connection with the database by using cx_Oracle, it works. Next I try to write the dataframe df into the table TEST. This table TEST is an empty table which already exist in oracle database, it has columns including DATE, YEAR, MONTH, SOURCE, DESTINATION in oracle. All the datatype matches the df sample data. My code is as follows:</p>
  
  <pre><code>conn_str = u'account/password@host:1521/server'
  conn = cx_Oracle.connect(conn_str)
  
  # Write records stored in a DataFrame to a oracle database
  df.to_sql('TEST', conn, if_exists='replace') # the error shows here
  
  conn.close()
  </code></pre>
  
  <p>It shows error:</p>
  
  <blockquote>
    <p>DatabaseError: Execution failed on sql 'SELECT name FROM sqlite_master
    WHERE type='table' AND name=?;': ORA-01036: illegal variable
    name/number</p>
  </blockquote>
  
  <p>How to solve the problem? Thank you very much for your time!</p>