MySQL Workcench conexión con Python
Conexión de Workbench con Python.
Tabla con datos insertados desde Python.
Tabla con datos insertados desde Python.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pymysql.connections | |
db = pymysql.connect(host='localhost', user='root', password='cynthia1', db='escuela') | |
cursor = db.cursor() | |
sql = "INSERT INTO alumnos (idalumnos, Salon, Nombre) VALUES (%s, %s, %s)" | |
val = (17260576, "6A", "Juan Banda") | |
cursor.execute(sql, val) | |
db.commit() | |
print(cursor.rowcount, "record inserted.") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pymysql | |
db = pymysql.connect(host='localhost',user='root',password='cynthia1',db='inventario') | |
cursor = db.cursor() | |
cursor.execute("SELECT VERSION()") | |
data = cursor.fetchone() | |
print ("Database version : {0}".format(data)) | |
db.close() |
Comentarios
Publicar un comentario