Python with MySQL connector, no information being sent to database -
i trying send data database hosted on web using python. there no mysql errors being thrown running in ninja output:
traceback (most recent call last): file "/home/nekasus/tryme.py", line 8, in <module> port = "3306") # name of data base file "/usr/lib/python2.7/dist-packages/mysqldb/__init__.py", line 81, in connect return connection(*args, **kwargs) file "/usr/lib/python2.7/dist-packages/mysqldb/connections.py", line 187, in __init__ super(connection, self).__init__(*args, **kwargs2) typeerror: integer required this code:
import fakevalues import mysqldb fakevalues.randomnumber() db = mysqldb.connect(host="sql8.freemysqlhosting.net", user="sql8167767", passwd="placeholder", db="sql8167767", port = "3306") cur = db.cursor() try: cur.execute("insert hydroponics (ph, electricalconductivity, nutrientsolutiontemperature, nutrientsolutiondepth) values (1, 1, 1, 1)") except mysqldb.error e: print(e) db.close()
you missing commit.
db.commit()
Comments
Post a Comment