ODBC TO microsoft sql server 2014 - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Networking (https://python-forum.io/forum-12.html) +--- Thread: ODBC TO microsoft sql server 2014 (/thread-2573.html) |
ODBC TO microsoft sql server 2014 - Papom - Mar-25-2017 hello, please help! i am soo frustrated... what am i doing wrong? import pyodbc server = 'SQLEXPRESS' database = 'TSQL2012' username = 'user' password = 'pass' driver= '{ODBC Driver 11 for SQL Server}' cnxn = pyodbc.connect('DRIVER='+driver+';PORT=1433;SERVER='+server+';PORT=1443;DATABASE='+database+';UID='+username+';PWD='+ password) cursor = cnxn.cursor() cursor.execute("select * from [Production].[Categories]") row = cursor.fetchone() if row: print row
Moderator Larz60+: Removed formatting, added tags - Pease read how to post see: https://python-forum.io/misc.php?action=help&hid=25 RE: ODBC TO microsoft sql server 2014 - Larz60+ - Mar-25-2017 Clean up your post if you want help. Not sure anyone wants to deal with this mess. RE: ODBC TO microsoft sql server 2014 - Papom - Mar-25-2017 I'd love to do this, but I do not know how to do that.... RE: ODBC TO microsoft sql server 2014 - nilamo - Mar-26-2017 I don't think this is related to your issue, but why are you using version 11? Isn't 13 the newest? Do you need to create an odbc connection? https://docs.microsoft.com/en-us/sql/odbc/admin/odbc-data-source-administrator Do you have the odbc drivers installed? (just the python package isn't enough) https://www.microsoft.com/en-us/download/details.aspx?id=50420 Can you access the database from an external program, to verify you have the right connection info? Microsoft SQL Management Studio is a good way to quickly check. RE: ODBC TO microsoft sql server 2014 - Papom - Mar-27-2017 hey i fix it with ODBC driver 11 for sql server and add this line code: "Trusted_Connection=Yes" to the pyodbc.connect object 10x for the hlp |