好的,我正在试图弄清楚如何将我的变量传递给我的方法,这是最简单的部分。我遇到的主要问题是我需要在我的方法中使用该变量的值等于WHERE语句中的值。 我被告知使用%s来等于传递的值,但是MariaDB不喜欢语法。任何帮助将不胜感激。
def ERRORDISPLAY(ErrorTpye):
#value = ErrorType
conn = connection.MySQLConnection(user = 'user', password = '123456',
host = 'localhost', database= 'HomeConnect')
cursor = conn.cursor()
query = ("SELECT errNumber, description FROM Error_List WHERE errNumber = %s value %s")
num = ErrorType
cursor.execut(query,(num))
for (description) in cursor:
return print(num, description)
ERRORDISPLAY(1)
答案 0 :(得分:-1)
我弄明白了。我必须将整数转换为字符串。出于某种原因,MariaDB for Pi W不喜欢某些语法。所以看起来应该是这样的:
IOError: closed stream
from /var/www/my_app/shared/bundle/ruby/2.4.0/gems/aws-sdk-resources-2.10.126/lib/aws-sdk-resources/services/s3/file_uploader.rb:31:in `size'
from /var/www/my_app/shared/bundle/ruby/2.4.0/gems/aws-sdk-resources-2.10.126/lib/aws-sdk-resources/services/s3/file_uploader.rb:31:in `upload'
from /var/www/my_app/shared/bundle/ruby/2.4.0/gems/aws-sdk-resources-2.10.126/lib/aws-sdk-resources/services/s3/object.rb:252:in `upload_file'
from (irb):44