-
-
Save parzibyte/bddca5dad97b431d0061d8d9abcbd0a8 to your computer and use it in GitHub Desktop.
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
""" | |
Conexión a PostgreSQL con Python | |
Ejemplo de CRUD evitando inyecciones SQL | |
@author parzibyte | |
Más tutoriales en: | |
parzibyte.me/blog | |
""" | |
import psycopg2 | |
# Recomendado: https://parzibyte.me/blog/2018/12/20/args-kwargs-python/ | |
try: | |
credenciales = { | |
"dbname": "mascotas", | |
"user": "parzibyte", | |
"password": "hunter2", | |
"host": "localhost", | |
"port": 5432 | |
} | |
conexion = psycopg2.connect(**credenciales) | |
except psycopg2.Error as e: | |
print("Ocurrió un error al conectar a PostgreSQL: ", e) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment