Pyodbc: Login Timeout Error
Microsoft’s ODBC drivers for SQL Server do not use a PORT= parameter. The port number, if any, is appended to the server name/IP with a comma, e.g., SERVER=xxxTest-SRV,51333;
Microsoft’s ODBC drivers for SQL Server do not use a PORT= parameter. The port number, if any, is appended to the server name/IP with a comma, e.g., SERVER=xxxTest-SRV,51333;
From the pyodbc documentation To call a stored procedure right now, pass the call to the execute method using either a format your database recognizes or using the ODBC call escape format. (The ODBC driver will then reformat the call for you to match the given database.) For SQL Server you would use something like … Read more
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
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
You can use Homebrew to install unixodbc, then pyodbc via pip in the usual fashion. brew install unixodbc && pip install pyodbc This works for me on Mavericks.
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
As noted in a comment to another answer, the T-SQL BULK INSERT command will only work if the file to be imported is on the same machine as the SQL Server instance or is in an SMB/CIFS network location that the SQL Server instance can read. Thus it may not be applicable in the case … Read more
I believe the answer to your problem is that in your ~/.odbc.ini file you are saying to use driver PostgreSQL – but you have not defined that driver in your /etc/odbcinst.ini file. Try changing PostgreSQL to PostgreSQL ANSI or PostgreSQL Unicode (both of which are defined in /etc/odbcinst.ini).
Just in case some lonely net nomad comes across this issue, the solution by Torxed didn’t work for me. But the following worked for me. I was calling an SP which inserts some values into a table and then returns some data back. Just add the following to the SP : SET NOCOUNT ON It’ll … Read more
As has been stated, django-pyodbc is a good way to go. PyODBC is probably the most mature SQL Server library for Python there is. The only thing you may have problems with is that pyodbc doesn’t support stored procedures very well (you can call them, but you have no way to get results from them). … Read more