wpostgresql
Science Score: 44.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
✓CITATION.cff file
Found CITATION.cff file -
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
○Academic publication links
-
○Academic email domains
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (11.2%) to scientific vocabulary
Repository
Basic Info
- Host: GitHub
- Owner: wisrovi
- License: mit
- Language: Python
- Default Branch: main
- Size: 15.6 KB
Statistics
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
- Releases: 1
Metadata Files
README.md
wpostgresql
wpostgresql is a library for specific functions for interacting with PostgreSQL databases.
Description
wpostgresql simplifies code for interacting with PostgreSQL databases. It provides a number of functions for creating, reading, updating, and deleting data in PostgreSQL databases.
Installation
To install the library, use pip:
bash
pip install wpostgresql
Description
The wpostgresql library offers a number of general-purpose modules.
License
MIT
This project is licensed under the MIT License. See the LICENSE file for details.
Examples
This directory contains a collection of examples that demonstrate the usage of various modules and functionalities in this project. Each subfolder corresponds to a specific module and includes example scripts to help you understand how to use that module.
Directory Structure
The examples are organized as follows:
examples/
wpostgresql/
crupd.py
new_columns.py
with_restrictions.py
How to Use
- Navigate to the module folder of interest, e.g.,
examples/module1/. - Open the
README.mdin that folder to get detailed information about the examples. - Run the scripts directly using:
bash python example1.py
Modules and Examples
wpostgresql
Description
This module demonstrates specific functionalities.
- crupd.py: Example demonstrating functionality. ```python from pydantic import BaseModel from wpostgresql import WPostgreSQL # Asegúrate de tener definida la clase WPostgreSQL
Configuración de conex ión a PostgreSQL
db_config = { 'dbname': 'wpostgresql', 'user': 'postgres', 'password': 'postgres', 'host': 'localhost', 'port': 5432 }
Definir el modelo sin restricciones adicionales
class SimpleModel2(BaseModel): id: int name: str age: int is_active: bool
Crear la base de datos y la tabla (se crean o sincronizan automáticamente)
db = WPostgreSQL(SimpleModel2, db_config)
Insertar datos
db.insert(SimpleModel2(id=1, name="Juan Pérez", age=30, isactive=True)) db.insert(SimpleModel2(id=2, name="Ana López", age=25, isactive=True)) db.insert(SimpleModel2(id=3, name="Pedro Gómez", age=40, is_active=False))
Consultar todos los registros
print("Todos los usuarios:", db.get_all())
Consultar por un campo específico
print("Usuarios llamados Juan Pérez:", db.getbyfield(name="Juan Pérez"))
Consultar por múltiples filtros
print("Usuarios activos con 25 años:", db.getbyfield(age=25, is_active=True))
Actualizar un usuario (por ejemplo, actualizando el registro con id=1)
db.update(1, SimpleModel2(id=1, name="Juan Pérez", age=31, isactive=False)) print("Usuario actualizado (id=1):", db.getby_field(id=1))
Eliminar un usuario (por ejemplo, el de id=3)
db.delete(3) print("Usuarios después de eliminar a Pedro Gómez:", db.get_all()) ```
- new_columns.py: Example demonstrating functionality. ```python from pydantic import BaseModel, Field from typing import Optional from wpostgresql import WPostgreSQL
db_config = { 'dbname': 'wpostgresql', 'user': 'postgres', 'password': 'postgres', 'host': 'localhost', 'port': 5432 }
Modelo inicial sin el campo email
class SimpleModel4(BaseModel): id: int = Field(..., description="Primary Key") name: str = Field(..., description="NOT NULL") age: int is_active: bool
Crear la tabla con el modelo inicial e insertar un registro
db = WPostgreSQL(SimpleModel4, dbconfig) db.insert(SimpleModel4(id=1, name="Ana López", age=25, isactive=True))
=== AHORA SE AÑADE UN NUEVO CAMPO AL MODELO ===
class SimpleModel4(BaseModel): id: int = Field(..., description="Primary Key") name: str = Field(..., description="NOT NULL") age: int is_active: bool email: Optional[str] # Nuevo campo sin restricciones en la base de datos
Al instanciar nuevamente WPostgreSQL con el modelo actualizado se sincroniza la tabla
db = WPostgreSQL(SimpleModel4, db_config)
Insertar un nuevo registro que incluya el nuevo campo
db.insert(SimpleModel4(id=2, name="Ana López", age=25, is_active=True, email="ana@example.com"))
Mostrar todos los registros después de la actualización
print("Usuarios después de actualizar el modelo:", db.get_all()) ```
- with_restrictions.py: Example demonstrating functionality. ```python from pydantic import BaseModel, Field from typing import Optional from wpostgresql import WPostgreSQL
db_config = { 'dbname': 'wpostgresql', 'user': 'postgres', 'password': 'postgres', 'host': 'localhost', 'port': 5432 }
Definir el modelo con restricciones
class SimpleModel5(BaseModel): id: int = Field(..., description="Primary Key") name: str = Field(..., description="NOT NULL") age: int is_active: bool email: Optional[str] = Field(None, description="UNIQUE") # Email debe ser único
Crear la base de datos y sincronizar con el modelo
db = WPostgreSQL(SimpleModel5, db_config)
Insertar un registro válido
db.insert(SimpleModel5(id=1, name="Juan Pérez", age=30, is_active=True, email="juan@example.com"))
Intentar insertar un registro con un email duplicado (esto debería fallar)
try: db.insert(SimpleModel5(id=2, name="Ana López", age=25, is_active=True, email="juan@example.com")) except Exception as e: print("Error al insertar usuario duplicado:", e)
Insertar otro registro con un email único (esto funcionará)
db.insert(SimpleModel5(id=3, name="Pedro Gómez", age=40, is_active=False, email="pedro@example.com"))
Mostrar los registros almacenados
print("Usuarios en la base de datos:", db.get_all()) ```
Owner
- Name: William Rodriguez
- Login: wisrovi
- Kind: user
- Location: Colombia
- Website: https://www.linkedin.com/in/wisrovi-rodriguez/
- Repositories: 7
- Profile: https://github.com/wisrovi
Citation (CITATION.cff)
cff-version: 1.2.0 message: "If you use this software, please cite it as below." authors: - family-names: "WISROVI" given-names: "William Steve Rodriguez Villamizar" title: " Libreria python para hacer data augmentation en audios y/o extraer caracteristicas a audios" version: 0.22.10 date-released: 2022-10-12 url: "https://github.com/wisrovi/ProcessAudio"
GitHub Events
Total
- Release event: 1
- Push event: 1
- Create event: 3
Last Year
- Release event: 1
- Push event: 1
- Create event: 3
Packages
- Total packages: 1
-
Total downloads:
- pypi 26 last-month
- Total dependent packages: 0
- Total dependent repositories: 0
- Total versions: 1
- Total maintainers: 1
pypi.org: wpostgresql
Utilities for Python in postgresql
- Homepage: https://github.com/wisrovi/wpostgresql
- Documentation: https://wpostgresql.readthedocs.io/
- License: MIT License Copyright (c) 2025 William Rodriguez Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
Latest release: 0.1.0
published about 1 year ago
Rankings
Maintainers (1)
Dependencies
- actions/checkout v4 composite
- actions/setup-python v3 composite
- actions/checkout v4 composite
- actions/setup-python v3 composite
- loguru *
- psycopg2 *
- psycopg2-binary *
- pydantic *
- setuptools *
- tomli *
- loguru >=0.7.0