psqleasy 1.0.5
Ultra-simple PostgreSQL interface for Python
License: MIT
Requires Python: >=3.7
Keywords: postgresql, postgres, database, sql, orm, psycopg2

## PsqlEasy - PostgreSQL Made Simple

[![PyPI version](https://img.shields.io/pypi/v/psqleasy.svg)](https://pypi.org/project/psqleasy/)
[![Python Version](https://img.shields.io/pypi/pyversions/psqleasy)](https://pypi.org/project/psqleasy/)
[![License](https://img.shields.io/pypi/l/psqleasy)](https://opensource.org/licenses/MIT)

PsqlEasy is a Python library designed to make working with PostgreSQL databases as simple as possible.
It provides an intuitive interface for common database operations without requiring complex SQL knowledge.

## Features

- ✅ **Easy Connection Management** - Context managers for automatic connection handling
- 🔒 **SQL Injection Protection** - Built-in parameterized queries
- 🛠️ **Full CRUD Operations** - Simple functions for Create, Read, Update, Delete
- 🔍 **Schema Inspection** - View tables and columns easily
- 🚀 **Unified Query Interface** - One function for all common operations
- ⚡ **Lightweight** - Single dependency (psycopg2-binary)
- 🆕 **Create Database Support** - Create a new PostgreSQL database directly
- 🧪 **Raw SQL Execution** - Pass raw SQL directly via query()

## Installation

```bash
pip install psqleasy
```

## Quick Start

```python
import psqleasy as psql

# Connect to database
with psql.connect("localhost", "user", "password", 5432, "mydb") as conn:
    # Create table
    psql.create_table(conn, "users", {
        "id": "SERIAL PRIMARY KEY",
        "name": "VARCHAR(100)",
        "email": "VARCHAR(255) UNIQUE"
    })

    # Insert data
    psql.insert_data(conn, "users", {
        "name": "John Doe",
        "email": "john@example.com"
    })

    # View data
    users = psql.view_data(conn, "users")
    print(users)
```

## Core Functions

### Connection Management
```python
with psql.connect(host, user, passwd, port, db) as conn:
    # Your database operations
```

### CRUD Operations
```python
# Create table
psql.create_table(conn, "products", {
    "id": "SERIAL PRIMARY KEY",
    "name": "VARCHAR(100)",
    "price": "DECIMAL(10,2)"
})

# Insert data
psql.insert_data(conn, "products", {
    "name": "Laptop",
    "price": 999.99
})

# View data
products = psql.view_data(conn, "products")

# Update data
psql.update_data(conn, "products",
    {"price": 899.99},
    "name = %s", ("Laptop",)
)

# Delete data
psql.delete_data(conn, "products",
    "name = %s", ("Laptop",)
)
```

### Schema Management
```python
# List all tables
tables = psql.show_tables(conn)

# Show table columns
columns = psql.show_columns(conn, "products")

# Drop table
psql.drop_table(conn, "temp_table")
```

### Advanced Features
```python
# Raw SQL query via unified interface
result = psql.query(
    conn,
    "SELECT * FROM products WHERE price > %s",
    params=(100,)
)

# Unified query interface for built-in operations
psql.query(conn, 'create', table_name="orders", columns={
    "id": "SERIAL PRIMARY KEY",
    "product_id": "INTEGER"
})

orders = psql.query(conn, 'select', table_name="orders")
```

### Supported operations in query()
- `'create_db'`: Create a new database
- `'create'`: Create a table
- `'insert'`: Insert data
- `'select'`: Select data
- `'update'`: Update rows
- `'delete'`: Delete rows
- `'drop'`: Drop table
- `'tables'`: Show table list
- `'columns'`: Show column info
- ✅ **Supports raw SQL**: `SELECT`, `INSERT`, `UPDATE`, `DELETE`, etc.

## Documentation

For complete documentation with detailed examples, please see:

📚 https://sheikhtanvirsiddiki.github.io/psqleasy/

## Contributing

Contributions are welcome! Please open an issue or submit a pull request.

1. Fork the repository
2. Create your feature branch (`git checkout -b feature/your-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin feature/your-feature`)
5. Open a pull request

## License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

---

<p align="center">
  <i>PostgreSQL made simple for Python developers</i>
</p>