SQLAlchemy and Oracle 12c Connection Issues
<p>I am using SQLAlchemy CORE (1.0.12) on Python 3.5 to connect with my organization's Oracle database. My database scripts worked without issue until my organization upgraded the Oracle database from 11g to 12c. After the upgrade I commonly run into the error below when trying to INSERT data into existing tables.</p>

<pre><code>sqlalchemy.exc.OperationalError: (cx_Oracle.OperationalError) ORA-03135: connection lost contact
Process ID: 10355
Session ID: 184 Serial number: 60376
</code></pre>

<p>I did not change any of the SQLAlchemy scripts during the upgrade and the error <strong>does not</strong> always occur, generally only happening when I am trying to insert large datasets. I have researched issues associated with the ORA-03135 error code and confirmed that I am not experiencing any firewall issues (I am able to connect sometimes) or timeouts (error prompt appears within seconds which is much too soon for timeout).</p>

<p>Has anyone else had this issue and found a solution?</p>

<pre><code>Traceback (most recent call last):
  File "C:\ross\repository\Analytics\OptTekSQL\run.py", line 5, in &lt;module&gt;
'Demand Analysis 8/17/16')
  File "C:\ross\repository\Analytics\OptTekSQL\optsql\data_load.py", line 43, in demand_output_load
s.insert_df(df, 'ACCDC_DEMAND_OUTPUTS')
  File "C:\ross\repository\Analytics\OptTekSQL\optsql\base.py", line 38, in insert_df
self.eng.connect().execute(ins, data)
  File "C:\Users\palmer\AppData\Local\Continuum\Anaconda2\envs\py3\lib\site-packages\sqlalchemy\engine\base.py", line 914, in execute
return meth(self, multiparams, params)
  File "C:\Users\palmer\AppData\Local\Continuum\Anaconda2\envs\py3\lib\site-packages\sqlalchemy\sql\elements.py", line 323, in _execute_on_connection
return connection._execute_clauseelement(self, multiparams, params)
  File "C:\Users\palmer\AppData\Local\Continuum\Anaconda2\envs\py3\lib\site-packages\sqlalchemy\engine\base.py", line 1010, in _execute_clauseelement
compiled_sql, distilled_params
  File "C:\Users\palmer\AppData\Local\Continuum\Anaconda2\envs\py3\lib\site-packages\sqlalchemy\engine\base.py", line 1146, in _execute_context
context)
  File "C:\Users\palmer\AppData\Local\Continuum\Anaconda2\envs\py3\lib\site-packages\sqlalchemy\engine\base.py", line 1341, in _handle_dbapi_exception
exc_info
  File "C:\Users\palmer\AppData\Local\Continuum\Anaconda2\envs\py3\lib\site-packages\sqlalchemy\util\compat.py", line 200, in raise_from_cause
reraise(type(exception), exception, tb=exc_tb, cause=cause)
  File "C:\Users\palmer\AppData\Local\Continuum\Anaconda2\envs\py3\lib\site-packages\sqlalchemy\util\compat.py", line 183, in reraise
raise value.with_traceback(tb)
  File "C:\Users\palmer\AppData\Local\Continuum\Anaconda2\envs\py3\lib\site-packages\sqlalchemy\engine\base.py", line 1116, in _execute_context
context)
  File "C:\Users\palmer\AppData\Local\Continuum\Anaconda2\envs\py3\lib\site-packages\sqlalchemy\dialects\oracle\cx_oracle.py", line 964, in do_executemany
cursor.executemany(statement, parameters)
</code></pre>