Hi, I am new to Python and I started immediately from importing data I am planning to analyse in pandas(?) to get tables, mean scores etc. I know how I can import that from excel but I have issues with importing data from ODBC. I can do it in excel, in SPSS and in R using this code:
abc <- odbcConnect("asa")
Country <- sqlQuery(abc, "SELECT * FROM dbo.tblCountry")
I am trying to replicate it in Python using this:
Unfortunately, I have this error:
abc <- odbcConnect("asa")
Country <- sqlQuery(abc, "SELECT * FROM dbo.tblCountry")
I am trying to replicate it in Python using this:
1 2 3 4 5 6 7 8 9 |
import pandas.io.sql import pyodbc import sys server = 'asa' db = 'dbo.tblCountry' conn = pyodbc.connect(server = server, database = db) print (conn) |
Error:pyodbc.InterfaceError: ('IM002', '[IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified (0) (SQLDriverConnect)')
What am I doing wrong?
Larz60+ write Jan-31-2022, 05:57 PM:
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Fixed for you this time. Please use BBcode tags on future posts.
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Fixed for you this time. Please use BBcode tags on future posts.