0
votes

I am looking for a solution for inserting CSV file to SQL Server and for inserting data to SQL Server I faced with below error. I read lot about this issue and did several changes but nothing happened and still I can't import csv to relative table. I can't understand why this error also happened?

Microsoft SQL has been installed on my local computer:

conn = pyodbc.connect('Driver=SQL Server; Server=ServerName\MSSQLSERVER; Database=DBName;Trusted_Connection=yes ; UID=Administrator')

Error:

pyodbc.OperationalError: ('08001', '[08001] [Microsoft][ODBC SQL Server Driver][DBMSLPCN]Invalid connection. (14) (SQLDriverConnect); [08001] [Microsoft][ODBC SQL Server Driver][DBMSLPCN]ConnectionOpen (ParseConnectParams()). (14)')

1
Why have you tagged MySQL if you are using SQL Server?Dale K
I'm not sure if that matters, but connection string should be 'DRIVER={SQL Server};SERVER=.... (missing {}).Zhorov
I add {} , but the same error I got .Sara Daniel
Choose one authentication scheme. For Windows authentication use Trusted_Connection=yes without UID or PWD. For SQL Login authentication use UID=YourUsername;PWD=YourPassword without Trusted_Connection.AlwaysLearning
I am now connecting with SQL Authentication, I removed Trusted_Connection ='yes' and add user name and password instea but the same error i faced.Sara Daniel

1 Answers

0
votes

For anyone who faced with above problem,If you want to connect to sql server with SQL Authentication, the format will be changed as below:

pyodbc.connect('Driver={SQL Server}; Server=ServerName; Database=DBName; UID=UserName; PWD= {Password};')