Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- #
- """
- pip install pymysql
- python -m pip install pymysql
- """
- import pymysql
- # como conectarse a una base de datos
- conn = pymysql.connect(
- host = "localhost",
- user = "nombre_del_usuario",
- passwd = "contraseña",
- db = "nombre_base_datos"
- )
- # como agregar datos (usando el ejemplo de la tabla personas)
- for nombre, edad in personas:
- cursor.execute("INSERT INTO personas VALUES (%s, %s)",(nombre, edad))
- """
- excepciones: pymysql.err.InternalError sintaxis
- pymysql.ProgrammingError
- """
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement