それで、私は今日Pythonを使い始めました。をインストールしたpython-mysql.connector
ので、いくつかのクエリの作成を開始し、Python 内で結果を処理してから、いくつかのデータを LCD 画面に出力できます。
これが私が持っているものであることを知っています....
#!/usr/bin/python
import Adafruit_CharLCD
import mysql.connector
class LCDTests:
def __init__(self):
self.lcd = Adafruit_CharLCD;
#self.lcd.begin(16,1);
try:
cnx = mysql.connector(user = '', password='' database='', host='')
except mysql.connector.Error, e:
try:
print "MySQL Error [%d]: %s" % (e.args[0], e.args[1])
except IndexError:
print "MySQL Error: %s" % str(e)
else:
cnx.close()
def run(self):
print('alex')
#lcd.message('loading...');
test = LCDTests()
test.run()
しかし、実行./test.py
するたびに、次の出力が得られます。
Traceback (most recent call last):
File "./test.py", line 31, in <module>
test = LCDTests()
File "./test.py", line 16, in __init__
cnx = mysql.connector(user = '...', password='...', database='...', host='...')
TypeError: 'module' object is not callable
問題を探しているときに見つけたものは何もありませんでしたが、問題を解決するのに本当に役立ちました...問題がどこにあるのか考えてみませんか?