Update readme, bump version

This commit is contained in:
hhh
2024-03-17 23:20:32 +02:00
parent 944a9fe869
commit 4d6d5fca32
2 changed files with 19 additions and 13 deletions

View File

@@ -1,10 +1,16 @@
# aiodatalite
[![Maintainability](https://api.codeclimate.com/v1/badges/985ef318eb057cefee4f/maintainability)](https://codeclimate.com/github/kotikotprojects/aiodatalite/maintainability)
[![Test Coverage](https://api.codeclimate.com/v1/badges/985ef318eb057cefee4f/test_coverage)](https://codeclimate.com/github/kotikotprojects/aiodatalite/test_coverage)
![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/kotikotprojects/aiodatalite/python-publish.yml)
[![Documentation Status](https://readthedocs.org/projects/aiodatalite/badge/?version=latest)](https://aiodatalite.readthedocs.io/en/latest/?badge=latest)
![PyPI - Version](https://img.shields.io/pypi/v/aiodatalite)
> [!WARNING]
> Original project is a hobby project and it should not be used for security-critical or user facing applications.
> The same goes for this fork
It should be noted that Datalite is not suitable for secure web applications, it really is only suitable for cases when you can trust user input.
[Full Documentation](https://aiodatalite.readthedocs.io/en/latest/)
Datalite is a simple Python
package that binds your dataclasses to a table in a sqlite3 database,
@@ -12,8 +18,6 @@ using it is extremely simple, say that you have a dataclass definition,
just add the decorator `@datalite(db_name="db.db")` to the top of the
definition, and the dataclass will now be bound to the file `db.db`
[Detailed API reference](https://datalite.readthedocs.io/en/latest/)
## Download and Install
You can install `aiodatalite` simply by
@@ -40,7 +44,7 @@ from dataclasses import dataclass
from aiodatalite import datalite
@datalite(db_path="db.db")
@datalite(db_path="db.db", automarkup=True)
@dataclass
class Student:
student_id: int
@@ -52,6 +56,8 @@ table name `student` and rows `student_id`, `student_name` with datatypes
integer and text, respectively. The default value for `student_name` is
`John Smith`.
Read more about types and restrictions (most of them have been removed thanks to pickle) in our docs
## Basic Usage
### Entry manipulation
@@ -64,10 +70,10 @@ the middle.
```python
student = Student(10, "Albert Einstein")
student.create_entry() # Adds the entry to the table associated in db.db.
await student.create_entry() # Adds the entry to the table associated in db.db.
student.student_id = 20 # Update an object on memory.
student.update_entry() # Update the corresponding record in the database.
student.remove_entry() # Removes from the table.
await student.update_entry() # Update the corresponding record in the database.
await student.remove_entry() # Removes from the table.
```
But what if you have created your object in a previous session, or wish
@@ -76,15 +82,13 @@ collected by the Python interpreter? `remove_from(class_, obj_id)` is
a function that can be used for this express purpose, for instance:
```python
remove_from(Student, 2) # Removes the Student with obj_id 2.
await remove_from(Student, 2) # Removes the Student with obj_id 2.
```
Object IDs are auto-incremented, and correspond to the order the entry were
inserted onto the system.
## Fetching Records
> [!WARNING]
> **Limitation! Fetch can only fetch limited classes correctly**: int, float, bytes and str!
Finally, you may wish to recreate objects from a table that already exist, for
this purpose we have the module `fetch` module, from this you can import `
@@ -93,7 +97,7 @@ former fetches a record from the SQL database given its unique object_id
whereas the latter checks if it is fetchable (most likely to check if it exists.)
```python
>>> fetch_from(Student, 2)
>>> await fetch_from(Student, 2)
Student(student_id=10, student_name='Albert Einstein')
```
@@ -110,6 +114,6 @@ and returns the object whose `field` equals the provided `value`.
#### Pagination
`datalite` also supports pagination on `fetch_if`, `fetch_all` and `fetch_where`,
`aiodatalite` also supports pagination on `fetch_if`, `fetch_all` and `fetch_where`,
you can specify `page` number and `element_count` for each page (default 10), for
these functions in order to get a subgroup of records.

View File

@@ -1,8 +1,10 @@
[tool.poetry]
name = "aiodatalite"
version = "0.7.3"
version = "1.0.0"
description = "A simple Python library to bind dataclasses with databases. Now asynchronous!"
authors = ["hhh <h@localhost>", "Ege Ozkan <egeemirozkan24@gmail.com>"]
documentation = "https://aiodatalite.readthedocs.io"
repository = "https://github.com/kotikotprojects/aiodatalite"
readme = "README.md"