import - pymssql.connect 错误 - 意外的关键字参数 'server'

标签 import module kernel connect pymssql

我正在尝试运行我编写的程序,但遇到了问题。是说第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'

最佳答案

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

关于import - pymssql.connect 错误 - 意外的关键字参数 'server',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32888632/

相关文章:

r - 使用 `fread` 将 csv 文件从存档导入 `R` 而不提取到磁盘

python:除了 namespace 冲突之外, from package import * 是否有缺点

ruby-on-rails - Ruby Module NameError——顺序很重要吗?

ruby - 模块嵌套在 instance_eval/exec 或 module_eval/exec 中

c - 在给定指针的情况下从内核内部访问内核内存

git - 在 Android Studio 导入期间维护目录结构

Powershell 模块 GUID

linux - 丢弃包含字符串 linux 内核模块的数据包

c - 为什么内核在访问 32 位系统的内核模块中的系统调用表后会出现 panic ?

java - 如何在 Eclipse 中导入外部 jar 文件并将项目导出为文件系统