1
i am facing problems while trying to insert the values of my variables into the database I am trying to do as follows
import MySQLdb
id = 4
idade = 18
nome = 'cebolinha'
email = '[email protected]'
db = MySQLdb.connect("localhost","devel","********","Cadastro")
cursor = db.cursor()
sql = 'INSERT INTO usuarios(id, idade, nome email) VALUES (id, idade, nome, email)'
cursor.execute(sql)
cursor.fetchone()
db.commit()
db.close()
when I go to see in the database is not entering the values of my variables and this returns me no error
now when I run the script this way it’s working
import MySQLdb
db = MySQLdb.connect("localhost","devel","********","Cadastro")
cursor = db.cursor()
sql = 'INSERT INTO usuarios(id, idade, nome email) VALUES (3, 17, "daniel", "[email protected]")'
cursor.execute(sql)
cursor.fetchone()
db.commit()
db.close()
recalling that I am using the python Mysqldb module
I edited the question because "phpmyadmin" is not a "database", read this to understand the differences: What is the difference between mysql and phpmyadmin?
– Guilherme Nascimento