Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 23160

SQLAlchemy error in Python 3.11 when trying to initialize a table; It used to work in Python 3.8

$
0
0

Running the code below. It used to run in version Python 3.8. Recently I upgraded to 3.11 and it stopped working. I upgraded both sqlalchemy and pyodbc.

I have longer code but posting up to the first step where it is failing.

import yfinance as yfimport pandas as pdimport sqlalchemy as sql#from sqlalchemy import Tablefrom sqlalchemy import selectfrom sqlalchemy.engine import URLfrom datetime import datetime as timport pyodbcconnection_string = (                    r"DRIVER={SQL Server};"                    r"SERVER=Server_Name;" # Actual name redacted                    r"Database=DB_Name;" # Actual name redacted                    r"UID=Domain\Username;" # Actual name redacted                    r"Trusted_Connection=yes;"                     )connection_url = URL.create("mssql+pyodbc",query={"odbc_connect": connection_string}) # Creates full connection url from connection stringengine = sql.create_engine(connection_url, use_setinputsizes=False)connection = engine.connect()metadata = sql.MetaData()initTable = sql.Table('Input_tickers', metadata, autoload=True, autoload_with=engine) # Specifys table to be queried#mQuery = select(initTable) # Selects ztb_input_tickers from variable#mResultProxy = connection.execute(mQuery) # Executes SQL query#mResultSet = mResultProxy.fetchall() # Gets Query result

Here is the error I get.

Python 3.11.3 (tags/v3.11.3:f3909b8, Apr  4 2023, 23:49:59) [MSC v.1934 64 bit (AMD64)] on win32Type "help", "copyright", "credits" or "license()" for more information.= RESTART: C:\Users\%Username%\AppData\Local\Programs\Python\Python311\Scripts\SimpleyCopyfromDB.py*Traceback (most recent call last):  File "C:\Users\%Username%\AppData\Local\Programs\Python\Python311\Scripts\SimpleyCopyfromDB.py", line 45, in <module>    initTable = sql.Table('Input_tickers', metadata, autoload=True, autoload_with=engine) # Specifys table to be queried  File "<string>", line 2, in __new__  File "C:\Users\%Username%\AppData\Local\Programs\Python\Python311\Lib\site-packages\sqlalchemy\util\deprecations.py", line 283, in warned    return fn(*args, **kwargs)  # type: ignore[no-any-return]  File "C:\Users\%Username%\AppData\Local\Programs\Python\Python311\Lib\site-packages\sqlalchemy\sql\schema.py", line 435, in __new__    return cls._new(*args, **kw)  File "C:\Users\%Username%\AppData\Local\Programs\Python\Python311\Lib\site-packages\sqlalchemy\sql\schema.py", line 489, in _new    with util.safe_reraise():  File "C:\Users\%Username%\AppData\Local\Programs\Python\Python311\Lib\site-packages\sqlalchemy\util\langhelpers.py", line 147, in __exit__    raise exc_value.with_traceback(exc_tb)  File "C:\Users\%Username%\AppData\Local\Programs\Python\Python311\Lib\site-packages\sqlalchemy\sql\schema.py", line 485, in _new    table.__init__(name, metadata, *args, _no_init=False, **kw)  File "C:\Users\%Username%\AppData\Local\Programs\Python\Python311\Lib\site-packages\sqlalchemy\sql\schema.py", line 859, in __init__    self._extra_kwargs(**kw)  File "C:\Users\%Username%\AppData\Local\Programs\Python\Python311\Lib\site-packages\sqlalchemy\sql\schema.py", line 1007, in _extra_kwargs    self._validate_dialect_kwargs(kwargs)  File "C:\Users\%Username%\AppData\Local\Programs\Python\Python311\Lib\site-packages\sqlalchemy\sql\base.py", line 590, in _validate_dialect_kwargs    raise TypeError(TypeError: Additional arguments should be named <dialectname>_<argument>, got 'autoload'

Viewing all articles
Browse latest Browse all 23160

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>