A simple and secure Python database package built on SQLite.
No server required.
Parameterized queries.
Easy to learn.
# RiceDB™
A simple and secure Python database package built on SQLite.
RiceDB is a lightweight Python package that simplifies SQLite database operations.
Instead of writing SQL for common tasks, you can use a clean and easy-to-read Python API.
RiceDB is designed for beginners, students, hobbyists, and developers who want a simple database solution without setting up a database server.
---
## Features
- Simple and readable Python API
- Built on SQLite
- No external database server required
- Lightweight and easy to use
- Safe parameterized queries
- Automatic table management
- Cross-platform
- Open source
---
## Installation
bash
pip install ricedb
---
## Quick Start
python
from ricedb import Database
db = Database("school.db")
db.create_table(
"students",
{
"id": "id",
"name": "str",
"age": "int",
"active": "bool",
"created_at": "timenow",
}
)
db.insert(
"students",
{
"name": "Amy",
"age": 16,
"active": True,
}
)
rows = db.read("students")
print(rows)
db.close()
---
## Supported Data Types
| RiceDB Type | SQLite Type |
|--------------|-------------|
| id | INTEGER PRIMARY KEY AUTOINCREMENT |
| int | INTEGER |
| float | REAL |
| str | TEXT |
| bool | INTEGER |
| bytes | BLOB |
| datetime | TEXT |
| timenow | CURRENT_TIMESTAMP |
---
## Main API
### Database
python
db = Database("example.db")
---
### Create Table
python
db.create_table(
"users",
{
"id": "id",
"name": "str",
"age": "int"
}
)
---
### Insert Data
python
db.insert(
"users",
{
"name": "Alice",
"age": 20
}
)
---
### Read Data
python
db.read("users")
Read with conditions
python
db.read(
"users",
where={
"age":20
}
)
---
### Get One Record
python
db.get(
"users",
where={
"id":1
}
)
Returns one dictionary or `None`.
---
### Update Data
python
db.update(
"users",
{
"age":21
},
where={
"id":1
}
)
---
### Delete Data
python
db.delete(
"users",
where={
"id":1
}
)
---
### Count Records
python
db.count("users")
---
### Check Record Exists
python
db.exists(
"users",
where={
"name":"Alice"
}
)
Returns
python
True
or
python
False
---
### Create Column
python
db.create_column(
"users",
"email",
"str"
)
---
### Delete Column
python
db.delete_column(
"users",
"email"
)
---
### Rename Column
python
db.rename_column(
"users",
"name",
"full_name"
)
---
### Rename Table
python
db.rename_table(
"users",
"members"
)
---
### Clear Table
python
db.clear_table("members")
---
### List Tables
python
db.list_tables()
---
### List Columns
python
db.list_columns("members")
---
### Table Information
python
db.table_info("members")
---
### Execute SQL
python
db.execute(
"SELECT * FROM members"
)
---
### Close Database
python
db.close()
---
## Example
python
from ricedb import Database
db = Database("example.db")
db.create_table(
"students",
{
"id":"id",
"name":"str",
"score":"float"
}
)
db.insert(
"students",
{
"name":"Amy",
"score":95.5
}
)
print(db.read("students"))
db.close()
---
## Requirements
- Python 3.9+
- SQLite (built into Python)
---
## Project Website
https://riceplatform.org/db
---
## Source Code
https://github.com/RicePlatform/RiceDB
---
## License
RiceDB is licensed under the GNU General Public License v3.0 (GPL-3.0).
See the LICENSE file for details.
---
## Author
HONG-CHI WU
---
© Rice Platform
If you like RiceDB, please support Rice Platform.
Visit Rice Platform