Metadata-Version: 2.1
Name: daacla
Version: 0.0.6
Summary: Python module to management `dataclass` objects using SQLite
Home-page: https://github.com/anekos/daacla
Author: anekos
Author-email: pypi@snca.net
License: UNKNOWN
Platform: UNKNOWN
Classifier: Programming Language :: Python :: 3.7
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: appdirs
Requires-Dist: pytest


# daacla

Python module to management `dataclass` objects using SQLite


# Usage

```
from dataclasses import dataclass
from datetime import datetime

from daacla import Daacla, table


@dataclass
@table(key='url')  # `key` means primary key
class Post:  # makes `Post` table on the `db` database
    url: str
    created_at: float


db = Daacla()

# Update/Insert a record
db.upsert(Post(url='https://example.com/page/1', created_at=datetime.now().timestamp()))

# Check existence of the record
print( db.exists(Post, key='https://example.com/page/1') )  # → True

# Check existence of the record
print( db.exists(Post, key='https://example.com/page/NOTHING') )  # → False

# Search
url = 'https://example.com/page/1'
for post in db.select(Post, 'url = ?', url):
  print(post.url)  # → https://example.com/page/1
```

