【问题标题】:pymssql.connect error - unexpected keyword argument 'server'pymssql.connect 错误 - 意外的关键字参数“服务器”
【发布时间】:2015-10-01 13:18:38
【问题描述】:

我正在尝试运行我制作的程序,但遇到了问题。它说第8行有错误?前几天它还在工作,我不确定它是否已更改。这可能是与数据库的连接错误吗??

import RPi.GPIO as GPIO
import datetime
import time
import pymssql

conn = pymssql.connect (server='192.168.0.223', user='iad', password='iad',database='inputData')
cursor = conn.cursor()
#cursor.execute('select * from yesno')
#row = cursor.fetchone()
#while row:
#       print str(row[0])
#       row = cursor.fetchone()

print("Welcome! Button live data:")

GPIO.setmode(GPIO.BCM)

GPIO.setup(18, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(23, GPIO.IN, pull_up_down=GPIO.PUD_UP)

while True:
        input_state = GPIO.input(18)
        input_state2 = GPIO.input(23)
        if input_state == False:
                print('Happy')
                print(time.strftime("%Y-%m-%d"))
                cursor.execute("INSERT INTO buttonsPressed (inputResult, date) VALUES ('yes', '" + time.strftime("%Y-%m-%d") + "')")
                conn.commit()
                time.sleep(1)

        if input_state2 == False:
                print('Not Happy')
                print(time.strftime("%Y-%m-%d"))
                cursor.execute("INSERT INTO buttonsPressed (inputResult, date) VALUES ('no', '" + time.strftime("%Y-%m-%d") + "')")
                conn.commit()
                time.sleep(1)

我收到此错误?:

File "buttonin.py", line 8, in <module>
    conn = pymssql.connect (server='192.168.0.223', user='iad', password='iad',database='inputData')
TypeError: connect() got an unexpected keyword argument 'server'

【问题讨论】:

    标签: import module kernel connect pymssql


    【解决方案1】:

    您可以使用 host="" 代替 server=""

    【讨论】:

      【解决方案2】:

      我也遇到了同样的错误。

      尝试升级 python pymssql 库。

      在 Ubuntu 中,您可以通过以下命令对其进行升级: 1. sudo apt-get install freetds-dev
      2. pip install pymssql --upgrade

      希望对你有所帮助。

      【讨论】:

        猜你喜欢
        • 2013-09-08
        • 2011-07-18
        • 1970-01-01
        • 1970-01-01
        • 2022-01-23
        • 2015-12-11
        • 2019-01-05
        • 2020-03-27
        • 2011-12-28
        相关资源
        最近更新 更多