Connect docker python to SQL server with pyodbc

Need to Run: sudo apt-get install gcc need to add a odbcinst.ini file containing: [FreeTDS]Description=FreeTDS Driver Driver=/usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.so Setup=/usr/lib/x86_64-linux-gnu/odbc/libtdsS.so need to add folowing to docker file ADD odbcinst.ini /etc/odbcinst.ini RUN apt-get update RUN apt-get install -y tdsodbc unixodbc-dev RUN apt install unixodbc-bin -y RUN apt-get clean -y need to change connection in .py to connection = … Read more

Get data from pandas into a SQL server with PYODBC

For the ‘write to sql server’ part, you can use the convenient to_sql method of pandas (so no need to iterate over the rows and do the insert manually). See the docs on interacting with SQL databases with pandas: http://pandas.pydata.org/pandas-docs/stable/io.html#io-sql You will need at least pandas 0.14 to have this working, and you also need … Read more

Connecting to SQL Server 2012 using sqlalchemy and pyodbc

The file-based DSN string is being interpreted by SQLAlchemy as server name = c, database name = users. I prefer connecting without using DSNs, it’s one less configuration task to deal with during code migrations. This syntax works using Windows Authentication: engine = sa.create_engine(‘mssql+pyodbc://server/database’) Or with SQL Authentication: engine = sa.create_engine(‘mssql+pyodbc://user:password@server/database’) SQLAlchemy has a thorough … Read more

tech