Skip to content

Instantly share code, notes, and snippets.

@snahor
Last active January 2, 2016 08:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save snahor/8277618 to your computer and use it in GitHub Desktop.
Save snahor/8277618 to your computer and use it in GitHub Desktop.
SQLA + pyodbc
[db_name]
host = 1.1.1.1
port = 1433
tds version = 8.0
client charset = UTF-8
apt-get install unixodbc unixodbc-dev freetds-dev tdsodbc
[FreeTDS]
Description=FreeTDS Driver
Driver=/usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.so
Setup=/usr/lib/x86_64-linux-gnu/odbc/libtdsS.so
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