Last active
January 2, 2016 08:39
-
-
Save snahor/8277618 to your computer and use it in GitHub Desktop.
SQLA + pyodbc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[db_name] | |
host = 1.1.1.1 | |
port = 1433 | |
tds version = 8.0 | |
client charset = UTF-8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apt-get install unixodbc unixodbc-dev freetds-dev tdsodbc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[FreeTDS] | |
Description=FreeTDS Driver | |
Driver=/usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.so | |
Setup=/usr/lib/x86_64-linux-gnu/odbc/libtdsS.so |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from urllib import quote_plus | |
from sqlalchemy import create_engine | |
engine = create_engine( | |
'mssql+pyodbc:///?odbc_connect=' + | |
quote_plus( | |
'DRIVER=FreeTDS;' | |
'SERVER=1.1.1.1;' | |
'PORT=1433;' | |
'DATABASE=db_name;' | |
'UID=db_user;' | |
'PWD=db_password;' | |
'TDS_Version=8.0;' | |
) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment