Metadata-Version: 2.2
Name: pica-dbapi
Version: 0.1.0
Summary: A lightweight and fun DBAPI built on pandas/csv 🎉. Supported SQL: SELECT, INSERT, UPDATE, DELETE, JOIN, GROUP BY.
Author-email: Naruhide KITADANaruhide <kitfactory@gmail.com>
License: MIT License
        
        Copyright (c) 2025 Naruhide KITADA
        
        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.
        
Project-URL: Homepage, https://github.com/kitfactory/pica
Project-URL: Documentation, https://github.com/kitfactory/pica#readme
Project-URL: Repository, https://github.com/kitfactory/pica
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: pandas>=1.0.0
Requires-Dist: sqlparse>=0.4.0
Requires-Dist: numpy>=1.18.0

# 🐼 Pica - Simple SQL Interface for Pandas DataFrames 

Pica is a lightweight Python library that provides a SQL interface for Pandas DataFrames, following the Python DB-API 2.0 specification. It allows you to interact with your DataFrames using familiar SQL syntax while leveraging the power of Pandas under the hood.

## ✨ Features

- 🔍 SQL-like interface for Pandas DataFrames
- 📊 Supports common SQL operations
- 🐍 Python DB-API 2.0 compliant
- 🚀 Easy to use and integrate
- 📝 CSV file support for persistence

## 🛠️ Installation

```bash
pip install pica
```

## 🎯 Quick Start

```python
import pica
import pandas as pd

# Create a connection
conn = pica.connect()

# Register a DataFrame as a table
df = pd.DataFrame({
    'id': [1, 2, 3],
    'name': ['Alice', 'Bob', 'Charlie'],
    'age': [25, 30, 35]
})

conn.register_table('users', df, {
    'id': 'INTEGER',
    'name': 'TEXT',
    'age': 'INTEGER'
})

# Execute SQL queries
cursor = conn.cursor()
cursor.execute("SELECT name, age FROM users WHERE age > 25")
results = cursor.fetchall()
print(results)  # [('Bob', 30), ('Charlie', 35)]
```

## 🔥 Supported SQL Operations

### SELECT
- Basic SELECT with column selection
- WHERE clause with comparison operators (=, >, <, >=, <=, !=)
- GROUP BY with aggregate functions (COUNT, SUM, AVG, MAX, MIN)
- ORDER BY (ASC/DESC)
- JOIN operations
- Aliases (AS)

Example:
```sql
SELECT name, AVG(age) as avg_age 
FROM users 
WHERE age > 25 
GROUP BY name 
ORDER BY avg_age DESC
```

### INSERT
- Basic INSERT INTO with VALUES

Example:
```sql
INSERT INTO users (name, age) VALUES ('David', 28)
```

### UPDATE
- UPDATE with WHERE clause

Example:
```sql
UPDATE users SET age = 29 WHERE name = 'Alice'
```

### DELETE
- DELETE with WHERE clause

Example:
```sql
DELETE FROM users WHERE age < 25
```

## 📊 Supported Data Types

- INTEGER
- REAL
- BOOLEAN
- DATE
- TEXT

## 🔄 Transaction Support

```python
conn = pica.connect()
try:
    # Perform operations
    cursor = conn.cursor()
    cursor.execute("UPDATE users SET age = 26 WHERE name = 'Alice'")
    conn.commit()
except:
    conn.rollback()
finally:
    conn.close()
```

## 📝 License

MIT License

## 🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.
