Cannot to connect to SQL Server using FreeTDS and ODBC (raspberry pi raspbian)
Using a Raspberry Pi with Raspbian 9, I'm trying to connect to an Azure SQL database using ODBC (pip installed it from the shell) with FreeTDS (version 108)
Up until now, I have tried the following:
In /etc/odbcinst.ini
:
[FreeTDS]
Description=FreeTDS Driver
Driver=/usr/lib/odbc/libtdsodbc.so
Setup=/usr/lib/odbc/libtdsS.so
In my /etc/odbc.ini
[name]
Driver=FreeTDS
ServerName = {MyServerString from Azure MS-SQL}
Database = {My database name from Azure MSQ-SQL}
TDS_Version = auto
In the FreeTDS.config
file:
Created this block:
[name]
host = {MyServerString from Azure MSQ SQL}
port = 1433
tds version = auto
When I run the following command:
tsql -S {name} -U {my_username} -P {my_password}
I get the result
No errors ( 1> )
So I believe I am connected to the database.
However, when I run my Python code. I get an error. My database connection block is below
#Database setup
conDEBUG = "DRIVER={FreeTDS};Database={MyDGName};SERVER=tcp:{MyDB}.database.windows.net;UID={myUID};PWD={myPWD}"
conDEBUG = urllib.parse.quote_plus(conDEBUG)
conDEBUG = "mssql+pyodbc:///?odbc_connect=%s" % conDEBUG
app.config['SQLALCHEMY_DATABASE_URI'] = conDEBUG
db = SQLAlchemy(app)
I also tried adding 'TDS_Version=auto' to the conDEBUG string, this didn't work either.
The specific error I am getting:
('08001', '[08001] [unixODBC][FreeTDS][SQL Server]Unable to connect to data source (0) (SQLDriverConnect)')
sql-server tsql raspbian pyodbc freetds
add a comment |
Using a Raspberry Pi with Raspbian 9, I'm trying to connect to an Azure SQL database using ODBC (pip installed it from the shell) with FreeTDS (version 108)
Up until now, I have tried the following:
In /etc/odbcinst.ini
:
[FreeTDS]
Description=FreeTDS Driver
Driver=/usr/lib/odbc/libtdsodbc.so
Setup=/usr/lib/odbc/libtdsS.so
In my /etc/odbc.ini
[name]
Driver=FreeTDS
ServerName = {MyServerString from Azure MS-SQL}
Database = {My database name from Azure MSQ-SQL}
TDS_Version = auto
In the FreeTDS.config
file:
Created this block:
[name]
host = {MyServerString from Azure MSQ SQL}
port = 1433
tds version = auto
When I run the following command:
tsql -S {name} -U {my_username} -P {my_password}
I get the result
No errors ( 1> )
So I believe I am connected to the database.
However, when I run my Python code. I get an error. My database connection block is below
#Database setup
conDEBUG = "DRIVER={FreeTDS};Database={MyDGName};SERVER=tcp:{MyDB}.database.windows.net;UID={myUID};PWD={myPWD}"
conDEBUG = urllib.parse.quote_plus(conDEBUG)
conDEBUG = "mssql+pyodbc:///?odbc_connect=%s" % conDEBUG
app.config['SQLALCHEMY_DATABASE_URI'] = conDEBUG
db = SQLAlchemy(app)
I also tried adding 'TDS_Version=auto' to the conDEBUG string, this didn't work either.
The specific error I am getting:
('08001', '[08001] [unixODBC][FreeTDS][SQL Server]Unable to connect to data source (0) (SQLDriverConnect)')
sql-server tsql raspbian pyodbc freetds
Try removingtcp:
fromSERVER=tcp:{MyDB}.database.windows.net
.protocol:servername
is supported by Microsoft's ODBC driver for SQL Server, but not by FreeTDS ODBC.
– Gord Thompson
Nov 22 '18 at 17:02
Tried it. No success.. same error
– user122661
Nov 22 '18 at 17:50
add a comment |
Using a Raspberry Pi with Raspbian 9, I'm trying to connect to an Azure SQL database using ODBC (pip installed it from the shell) with FreeTDS (version 108)
Up until now, I have tried the following:
In /etc/odbcinst.ini
:
[FreeTDS]
Description=FreeTDS Driver
Driver=/usr/lib/odbc/libtdsodbc.so
Setup=/usr/lib/odbc/libtdsS.so
In my /etc/odbc.ini
[name]
Driver=FreeTDS
ServerName = {MyServerString from Azure MS-SQL}
Database = {My database name from Azure MSQ-SQL}
TDS_Version = auto
In the FreeTDS.config
file:
Created this block:
[name]
host = {MyServerString from Azure MSQ SQL}
port = 1433
tds version = auto
When I run the following command:
tsql -S {name} -U {my_username} -P {my_password}
I get the result
No errors ( 1> )
So I believe I am connected to the database.
However, when I run my Python code. I get an error. My database connection block is below
#Database setup
conDEBUG = "DRIVER={FreeTDS};Database={MyDGName};SERVER=tcp:{MyDB}.database.windows.net;UID={myUID};PWD={myPWD}"
conDEBUG = urllib.parse.quote_plus(conDEBUG)
conDEBUG = "mssql+pyodbc:///?odbc_connect=%s" % conDEBUG
app.config['SQLALCHEMY_DATABASE_URI'] = conDEBUG
db = SQLAlchemy(app)
I also tried adding 'TDS_Version=auto' to the conDEBUG string, this didn't work either.
The specific error I am getting:
('08001', '[08001] [unixODBC][FreeTDS][SQL Server]Unable to connect to data source (0) (SQLDriverConnect)')
sql-server tsql raspbian pyodbc freetds
Using a Raspberry Pi with Raspbian 9, I'm trying to connect to an Azure SQL database using ODBC (pip installed it from the shell) with FreeTDS (version 108)
Up until now, I have tried the following:
In /etc/odbcinst.ini
:
[FreeTDS]
Description=FreeTDS Driver
Driver=/usr/lib/odbc/libtdsodbc.so
Setup=/usr/lib/odbc/libtdsS.so
In my /etc/odbc.ini
[name]
Driver=FreeTDS
ServerName = {MyServerString from Azure MS-SQL}
Database = {My database name from Azure MSQ-SQL}
TDS_Version = auto
In the FreeTDS.config
file:
Created this block:
[name]
host = {MyServerString from Azure MSQ SQL}
port = 1433
tds version = auto
When I run the following command:
tsql -S {name} -U {my_username} -P {my_password}
I get the result
No errors ( 1> )
So I believe I am connected to the database.
However, when I run my Python code. I get an error. My database connection block is below
#Database setup
conDEBUG = "DRIVER={FreeTDS};Database={MyDGName};SERVER=tcp:{MyDB}.database.windows.net;UID={myUID};PWD={myPWD}"
conDEBUG = urllib.parse.quote_plus(conDEBUG)
conDEBUG = "mssql+pyodbc:///?odbc_connect=%s" % conDEBUG
app.config['SQLALCHEMY_DATABASE_URI'] = conDEBUG
db = SQLAlchemy(app)
I also tried adding 'TDS_Version=auto' to the conDEBUG string, this didn't work either.
The specific error I am getting:
('08001', '[08001] [unixODBC][FreeTDS][SQL Server]Unable to connect to data source (0) (SQLDriverConnect)')
sql-server tsql raspbian pyodbc freetds
sql-server tsql raspbian pyodbc freetds
edited Nov 22 '18 at 5:10
marc_s
572k12811061253
572k12811061253
asked Nov 22 '18 at 2:27
user122661user122661
1112
1112
Try removingtcp:
fromSERVER=tcp:{MyDB}.database.windows.net
.protocol:servername
is supported by Microsoft's ODBC driver for SQL Server, but not by FreeTDS ODBC.
– Gord Thompson
Nov 22 '18 at 17:02
Tried it. No success.. same error
– user122661
Nov 22 '18 at 17:50
add a comment |
Try removingtcp:
fromSERVER=tcp:{MyDB}.database.windows.net
.protocol:servername
is supported by Microsoft's ODBC driver for SQL Server, but not by FreeTDS ODBC.
– Gord Thompson
Nov 22 '18 at 17:02
Tried it. No success.. same error
– user122661
Nov 22 '18 at 17:50
Try removing
tcp:
from SERVER=tcp:{MyDB}.database.windows.net
. protocol:servername
is supported by Microsoft's ODBC driver for SQL Server, but not by FreeTDS ODBC.– Gord Thompson
Nov 22 '18 at 17:02
Try removing
tcp:
from SERVER=tcp:{MyDB}.database.windows.net
. protocol:servername
is supported by Microsoft's ODBC driver for SQL Server, but not by FreeTDS ODBC.– Gord Thompson
Nov 22 '18 at 17:02
Tried it. No success.. same error
– user122661
Nov 22 '18 at 17:50
Tried it. No success.. same error
– user122661
Nov 22 '18 at 17:50
add a comment |
1 Answer
1
active
oldest
votes
Here's the function I use for connecting via SQLAlchemy to SQL Server over pyodbc
:
def mssql_connect(con_string):
""" Connects to the specified db via ODBC. """
def connect():
return pyodbc.connect(con_string, autocommit=True)
db = create_engine('mssql://', creator=connect, encoding='cp1252')
db.echo = False
return db
mssql_connect("DRIVER={FreeTDS};SERVER={MyDB}.database.windows.net;PORT=1433;DATABASE={dbname};UID={myUID};PWD={myPWD};TDS_Version=7.3;")
Depending on your version of FreeTDS, you may have to replace TDS_Version=7.3
with TDS_Version=7.2
or TDS_Version=7.1
. Good luck!
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53423067%2fcannot-to-connect-to-sql-server-using-freetds-and-odbc-raspberry-pi-raspbian%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Here's the function I use for connecting via SQLAlchemy to SQL Server over pyodbc
:
def mssql_connect(con_string):
""" Connects to the specified db via ODBC. """
def connect():
return pyodbc.connect(con_string, autocommit=True)
db = create_engine('mssql://', creator=connect, encoding='cp1252')
db.echo = False
return db
mssql_connect("DRIVER={FreeTDS};SERVER={MyDB}.database.windows.net;PORT=1433;DATABASE={dbname};UID={myUID};PWD={myPWD};TDS_Version=7.3;")
Depending on your version of FreeTDS, you may have to replace TDS_Version=7.3
with TDS_Version=7.2
or TDS_Version=7.1
. Good luck!
add a comment |
Here's the function I use for connecting via SQLAlchemy to SQL Server over pyodbc
:
def mssql_connect(con_string):
""" Connects to the specified db via ODBC. """
def connect():
return pyodbc.connect(con_string, autocommit=True)
db = create_engine('mssql://', creator=connect, encoding='cp1252')
db.echo = False
return db
mssql_connect("DRIVER={FreeTDS};SERVER={MyDB}.database.windows.net;PORT=1433;DATABASE={dbname};UID={myUID};PWD={myPWD};TDS_Version=7.3;")
Depending on your version of FreeTDS, you may have to replace TDS_Version=7.3
with TDS_Version=7.2
or TDS_Version=7.1
. Good luck!
add a comment |
Here's the function I use for connecting via SQLAlchemy to SQL Server over pyodbc
:
def mssql_connect(con_string):
""" Connects to the specified db via ODBC. """
def connect():
return pyodbc.connect(con_string, autocommit=True)
db = create_engine('mssql://', creator=connect, encoding='cp1252')
db.echo = False
return db
mssql_connect("DRIVER={FreeTDS};SERVER={MyDB}.database.windows.net;PORT=1433;DATABASE={dbname};UID={myUID};PWD={myPWD};TDS_Version=7.3;")
Depending on your version of FreeTDS, you may have to replace TDS_Version=7.3
with TDS_Version=7.2
or TDS_Version=7.1
. Good luck!
Here's the function I use for connecting via SQLAlchemy to SQL Server over pyodbc
:
def mssql_connect(con_string):
""" Connects to the specified db via ODBC. """
def connect():
return pyodbc.connect(con_string, autocommit=True)
db = create_engine('mssql://', creator=connect, encoding='cp1252')
db.echo = False
return db
mssql_connect("DRIVER={FreeTDS};SERVER={MyDB}.database.windows.net;PORT=1433;DATABASE={dbname};UID={myUID};PWD={myPWD};TDS_Version=7.3;")
Depending on your version of FreeTDS, you may have to replace TDS_Version=7.3
with TDS_Version=7.2
or TDS_Version=7.1
. Good luck!
answered Nov 23 '18 at 18:36
FlipperPAFlipperPA
6,95322043
6,95322043
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53423067%2fcannot-to-connect-to-sql-server-using-freetds-and-odbc-raspberry-pi-raspbian%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Try removing
tcp:
fromSERVER=tcp:{MyDB}.database.windows.net
.protocol:servername
is supported by Microsoft's ODBC driver for SQL Server, but not by FreeTDS ODBC.– Gord Thompson
Nov 22 '18 at 17:02
Tried it. No success.. same error
– user122661
Nov 22 '18 at 17:50