0

I am trying to connect to local MS SQL Express Edition. I am using canopy for Python editing.

Code:

import pymssql

conn = pymssql.connect(server='******\SQLEXPRESS',user = 'MEA\*****',password='*****',database='BSEG')

cursor = conn.cursor()

cursor.execute('SELECT * FROM Table')
print(cursor.fetchone())

conn.close()

Error::

pymssql.pyx in pymssql.connect (pymssql.c:10734)()

_mssql.pyx in _mssql.connect (_mssql.c:21821)()

_mssql.pyx in _mssql.MSSQLConnection.init (_mssql.c:5917)()

ValueError: too many values to unpack (expected 2)

Community
  • 1
  • 1

2 Answers2

0

user = 'MEA\*****',password='*****'

MEA\***** seems to be Windows login, in this case you shouldn't pass in any password, your user name is enough, but you also should use Integrated security or Trusted parameter in your connection string

It should be smth like this:

server='******\SQLEXPRESS',Trusted_Connection=yes,database='BSEG'
sepupic
  • 8,409
  • 1
  • 9
  • 20
  • Yes I am using windows login. Could you please provide me with the proper connection string. – Anuj Agarwal Sep 09 '17 at 18:28
  • I updated the answer, also, take a look here: https://stackoverflow.com/questions/16515420/connecting-to-ms-sql-server-with-windows-authentication-using-python – sepupic Sep 09 '17 at 18:35
0

In my local machine I only have the sql express instance, then after some tryes I get that server can be just ".". the user that I am using is sa

Jorge Raigoza
  • 11
  • 1
  • 1