informatica:base_de_datos:postgresql:start
Diferencias
Muestra las diferencias entre dos versiones de la página.
| Ambos lados, revisión anteriorRevisión previaPróxima revisión | Revisión previa | ||
| informatica:base_de_datos:postgresql:start [2025/09/15 08:18] – [Python : psycopg2 : ejemplo simple] admin | informatica:base_de_datos:postgresql:start [2026/02/05 06:34] (actual) – admin | ||
|---|---|---|---|
| Línea 4: | Línea 4: | ||
| < | < | ||
| psql | psql | ||
| + | </ | ||
| + | |||
| + | usar usuario local para conectarse a postgres | ||
| + | < | ||
| + | sudo -i -u postgres | ||
| </ | </ | ||
| Cuando se usa ; o \q para terminar un query en postgre sino no lo ejecuta. | Cuando se usa ; o \q para terminar un query en postgre sino no lo ejecuta. | ||
| + | |||
| + | seleccion DB a usar, como USE | ||
| + | < | ||
| + | \c < | ||
| + | </ | ||
| Listar Usuarios: | Listar Usuarios: | ||
| Línea 44: | Línea 54: | ||
| * [[https:// | * [[https:// | ||
| + | |||
| + | <code postgresql> | ||
| + | GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO < | ||
| + | </ | ||
| + | |||
| + | * [[https:// | ||
| + | |||
| ===== Tipo de Datos ===== | ===== Tipo de Datos ===== | ||
| Línea 54: | Línea 71: | ||
| + | gestion y backups automáticos: | ||
| + | * [[https:// | ||
| + | ===== Limites seteados ====== | ||
| - | ===== Python : psycopg2 : conexión : ejemplo simple ===== | + | |
| - | + | ||
| - | ejemplo simple: | + | |
| - | <code python> | + | |
| - | import psycopg2 | + | |
| - | + | ||
| - | cnx = psycopg2.connect( user="< | + | |
| - | password="< | + | |
| - | host="< | + | |
| - | port="< | + | |
| - | database="< | + | |
| - | + | ||
| - | print(" | + | |
| - | print(cnx.get_dsn_parameters(), | + | |
| - | + | ||
| - | </ | + | |
| - | + | ||
| - | Ejemplo simple con Try Catch: | + | |
| - | <code python> | + | |
| - | import psycopg2 | + | |
| - | + | ||
| - | try: | + | |
| - | + | ||
| - | cnx = psycopg2.connect( user="< | + | |
| - | password="< | + | |
| - | host="< | + | |
| - | port="< | + | |
| - | database="< | + | |
| - | + | ||
| - | print(" | + | |
| - | print(cnx.get_dsn_parameters(), | + | |
| - | + | ||
| - | except: | + | |
| - | + | ||
| - | print(" | + | |
| - | + | ||
| - | </ | + | |
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | | + | |
| - | * [[https:// | + | |
| - | * [[https:// | + | |
| - | * [[https:// | + | |
| - | * [[https:// | + | |
| - | + | ||
| - | ===== Python : psycopg2 : ejecutar : ejemplo simple ===== | + | |
| - | + | ||
| - | <code python> | + | |
| - | import psycopg2 | + | |
| - | + | ||
| - | try: | + | |
| - | + | ||
| - | cnx = psycopg2.connect( user="< | + | |
| - | password="< | + | |
| - | host="< | + | |
| - | port="< | + | |
| - | database="< | + | |
| - | + | ||
| - | print(" | + | |
| - | print(cnx.get_dsn_parameters(), | + | |
| - | + | ||
| - | cursor = cnx.cursor() | + | |
| - | cursor.execute(" | + | |
| - | + | ||
| - | cnx.commit() | + | |
| - | + | ||
| - | except: | + | |
| - | + | ||
| - | print(" | + | |
| - | + | ||
| - | + | ||
| - | </ | + | |
| - | * [[https:// | ||
| + | datos record: | ||
| + | * [[https:// | ||
informatica/base_de_datos/postgresql/start.1757924331.txt.gz · Última modificación: 2025/09/15 08:18 por admin
