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)
2条答案
按热度按时间tjjdgumg1#
user = 'MEA\*****',password='*****'
MEA\*****
seems to beWindows login
, in this case you shouldn't pass in any password, your user name is enough, but you also should useIntegrated security
orTrusted
parameter in your connection stringIt should be smth like this:
hivapdat2#
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