Mein Ziel ist eine Verbindung zu meiner MySQL-DB herzustellen. Ich habe als Vorlage folgendes Verwendet. https://www.w3schools.com/python/python ... select.asp Die DB ist zurzeit eine lokale die von XAMPP gestartet ist und funktioniert soweit auch. Der Port der DB ist unverändert und somit 3306, der Username und das Passwort ebenfalls. Danke für die Antworten schon im Voraus.
Mein Code:
Code: Alles auswählen
import importfile as ImF
import userData as Ud
class DB:
mydb = ImF.mysql.connector.connect(
host="127.0.0.1",
user="root",
password="",
database="ch283952_tst_citizen",
)
print(mydb)
pycursor = mydb.cursor()
mydb.mycursor.execute("SELECT firstname FROM citizen LIMIT 1")
myresult = mydb.mycursor.fetchone()
print(myresult)
if __name__ == "__main__":
DB()
AttributeError: 'MySQLConnection' object has no attribute 'mycursor'