This is nothing to do with SQLAlchemy directly but take a look at https://github.com/sqlalchemy/sqlalchemy/issues/5334 for a common situation that leads to this issue.
On Thu, Nov 12, 2020, at 9:18 PM, J Sherwood wrote: > Hello, > > I am moving an Oracle Database to SQL Server. > > I go through the table columns and create a dictionary of columnName: > sqlalchemy.types. and then push them to SQL Server using df.to_sql. > > Most tables work fine except when I have a large VARCHAR2 from Oracle of > 8000+ I need it to become a VARCHAR(max) in SQL Server so I use > sqalchemy.types.NVARCHAR(None) according to the documentation here > https://docs.sqlalchemy.org/en/13/dialects/mssql.html. > > When I run a table with this VSCode throws this error: > > Traceback (most recent call last): > > File "c:/Users/user/Desktop/Python/PythonFile.py", line 65, in <module> > > dfotable.to_sql(tn,engine, chunksize=1000, if_exists='replace', index = > False, dtype = dtypedict) > > File "C:\Users\user\Anaconda3\lib\site-packages\pandas\core\generic.py", > line 2653, in to_sql > > sql.to_sql( > > File "C:\Users\user\Anaconda3\lib\site-packages\pandas\io\sql.py", line > 512, in to_sql > > pandas_sql.to_sql( > > File "C:\Users\user\Anaconda3\lib\site-packages\pandas\io\sql.py", line > 1317, in to_sql > > table.insert(chunksize, method=method) > > File "C:\Users\user\Anaconda3\lib\site-packages\pandas\io\sql.py", line > 755, in insert > > exec_insert(conn, keys, chunk_iter) > > File "C:\Users\user\Anaconda3\lib\site-packages\pandas\io\sql.py", line > 669, in _execute_insert > > conn.execute(self.table.insert(), data) > > File "C:\Users\user\Anaconda3\lib\site-packages\sqlalchemy\engine\base.py", > line 1014, in execute > > return meth(self, multiparams, params) > > File > "C:\Users\user\Anaconda3\lib\site-packages\sqlalchemy\sql\elements.py", line > 298, in _execute_on_connection > > return connection._execute_clauseelement(self, multiparams, params) > > File "C:\Users\user\Anaconda3\lib\site-packages\sqlalchemy\engine\base.py", > line 1127, in _execute_clauseelement > > ret = self._execute_context( > > File "C:\Users\user\Anaconda3\lib\site-packages\sqlalchemy\engine\base.py", > line 1317, in _execute_context > > self._handle_dbapi_exception( > > File "C:\Users\user\Anaconda3\lib\site-packages\sqlalchemy\engine\base.py", > line 1515, in _handle_dbapi_exception > > util.raise_(exc_info[1], with_traceback=exc_info[2]) > > File "C:\Users\user\Anaconda3\lib\site-packages\sqlalchemy\util\compat.py", > line 178, in raise_ > > raise exception > > File "C:\Users\user\Anaconda3\lib\site-packages\sqlalchemy\engine\base.py", > line 1257, in _execute_context > > self.dialect.do_executemany( > > File > "C:\Users\user\Anaconda3\lib\site-packages\sqlalchemy\dialects\mssql\pyodbc.py", > line 416, in do_executemany > > super(MSDialect_pyodbc, self).do_executemany( > > File > "C:\Users\user\Anaconda3\lib\site-packages\sqlalchemy\engine\default.py", > line 590, in do_executemany > > cursor.executemany(statement, parameters) > > MemoryError > > Any help would be appreciated > > Thanks > > -- > SQLAlchemy - > The Python SQL Toolkit and Object Relational Mapper > > http://www.sqlalchemy.org/ > > To post example code, please provide an MCVE: Minimal, Complete, and > Verifiable Example. See http://stackoverflow.com/help/mcve for a full > description. > --- > You received this message because you are subscribed to the Google Groups > "sqlalchemy" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to sqlalchemy+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/sqlalchemy/f293da18-64ed-4e30-9ebf-bd199e7c01b0n%40googlegroups.com > > <https://groups.google.com/d/msgid/sqlalchemy/f293da18-64ed-4e30-9ebf-bd199e7c01b0n%40googlegroups.com?utm_medium=email&utm_source=footer>. -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper http://www.sqlalchemy.org/ To post example code, please provide an MCVE: Minimal, Complete, and Verifiable Example. See http://stackoverflow.com/help/mcve for a full description. --- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/sqlalchemy/c152b0c6-4eb9-4f7e-a1de-231c4d248888%40www.fastmail.com.