Last active
June 23, 2020 16:38
-
-
Save richard24se/70d524b13872f0f001989be6a3a0662b to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
# 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