# postgresql-python-demo **Repository Path**: longbhu/postgresql-python-demo ## Basic Information - **Project Name**: postgresql-python-demo - **Description**: 应用python操作postgresql数据库,批量上传tif文件 - **Primary Language**: Python - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-03-09 - **Last Updated**: 2026-03-09 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Python PostgreSQL 数据库操作项目 这是一个使用Python操作PostgreSQL数据库的示例项目,展示了基本的数据库连接、CRUD操作和连接池管理。 ## 功能特性 - 数据库连接池管理 - 基本的CRUD操作(创建、读取、更新、删除) - 参数化查询防止SQL注入 - 日志记录 - 错误处理 - 数据模型封装 ## 安装步骤 1. 克隆项目 ```bash git clone cd postgresql-python-demo 安装依赖 bash pip install -r requirements.txt 配置数据库 确保PostgreSQL已安装并运行 创建数据库:CREATE DATABASE testdb; 复制.env.example为.env并修改配置 运行示例 bash python examples/basic_operations.py 项目结构 src/database.py: 数据库连接和连接池管理 src/models.py: 数据模型定义 src/crud.py: CRUD操作实现 examples/: 示例程序 使用说明 基本用法 python from src.crud import UserCRUD # 创建用户表 UserCRUD.create_table() # 创建用户 user = UserCRUD.create_user({ 'username': 'test', 'email': 'test@example.com', 'age': 25 }) # 查询用户 users = UserCRUD.get_all_users()