Skip to content

Instantly share code, notes, and snippets.

@richard24se
Last active June 23, 2020 16:38
Show Gist options
  • Save richard24se/70d524b13872f0f001989be6a3a0662b to your computer and use it in GitHub Desktop.
Save richard24se/70d524b13872f0f001989be6a3a0662b to your computer and use it in GitHub Desktop.
import pymysql
# Connect to the database
connection = pymysql.connect(host=$IP_SERVIDOR,
user=$USUARIO,
password=$CONTRASEÑA,
db=$BASE_DATOS,
charset='utf8mb4',
)
try:
with connection.cursor() as cursor:
sql = "$QUERY"
cursor.execute(sql)
result = cursor.fetchall()
except Exception as error:
print(f"errores {error}")
finally:
connection.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment