-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e674b05
commit 8ad3c57
Showing
20 changed files
with
1,302 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
name: 'setup-poetry-env' | ||
description: "Composite action to setup the Python and poetry environment." | ||
|
||
inputs: | ||
python-version: | ||
required: false | ||
description: 'The python version to use' | ||
default: '3.11' | ||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Set up python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ inputs.python-version }} | ||
|
||
- name: Install Poetry | ||
uses: snok/install-poetry@v1 | ||
with: | ||
virtualenvs-in-project: true | ||
|
||
- name: Load cached venv | ||
id: cached-poetry-dependencies | ||
uses: actions/cache@v4 | ||
with: | ||
path: .venv | ||
key: venv-${{ runner.os }}-${{ inputs.python-version }}-${{ hashFiles('poetry.lock') }} | ||
|
||
- name: Install dependencies | ||
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true' | ||
run: poetry install --no-interaction | ||
shell: bash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
name: Publish docs via GitHub Pages | ||
on: | ||
push: | ||
tags: | ||
- 'v*' | ||
|
||
jobs: | ||
deploy-docs: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up the environment | ||
uses: ./.github/actions/setup-poetry-env | ||
|
||
- name: Deploy documentation | ||
run: poetry run mkdocs gh-deploy --force |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,4 @@ __pycache__/ | |
.env | ||
.pytest_cache/ | ||
dist/ | ||
site/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
## v0.0.5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
::: supadantic.clients.base.BaseClient |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
::: supadantic.clients.base.SingletoneMeta |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
::: supadantic.clients.cache.CacheClient |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
::: supadantic.clients.supabase.SupabaseClient |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
# Supadantic | ||
|
||
[![PyPI - Downloads](https://img.shields.io/pypi/dm/supadantic)](https://github.com/makridenko/supadantic) | ||
[![GitHub License](https://img.shields.io/github/license/makridenko/supadantic)](https://github.com/makridenko/supadantic) | ||
[![versions](https://img.shields.io/pypi/pyversions/supadantic.svg)](https://github.com/makridenko/supadantic) | ||
[![pypi](https://img.shields.io/pypi/v/supadantic.svg)](https://pypi.python.org/pypi/supadantic) | ||
|
||
Supadantic is a small Python library that allows you to manage [Supabase](https://supabase.com) tables through [Pydantic](https://github.com/pydantic/pydantic) models. It is very convenient to use in projects based on [FastAPI](https://github.com/tiangolo/fastapi), [Flask](https://github.com/pallets/flask), and so on. | ||
|
||
|
||
## Important information | ||
Supadantic may not have backward compatibility until version `0.1.0`. This is because the library is still experimental and is being used in several of my other projects, where requirements are still being finalized. | ||
|
||
|
||
## Installation | ||
|
||
Install using `pip install -U supadantic`. | ||
|
||
Also, you need to add `SUPABASE_URL` and `SUPABASE_KEY` to your env variables. | ||
|
||
|
||
## A Simple example | ||
|
||
```python | ||
from supadantic.models import BaseSBModel | ||
|
||
|
||
class User(BaseSBModel): | ||
# id field already defined in BaseSBModel class | ||
name: str = 'John Doe' | ||
is_active: bool = True | ||
|
||
# By default table name is class name in snake_case | ||
# If you want to change it - you should implement _get_table_name method | ||
@classmethod | ||
def _get_table_name(cls) -> str: | ||
return 'db_user' | ||
|
||
# Save user | ||
active_user = User(name='John Snow') | ||
active_user.save() | ||
|
||
non_active_user = User(is_active=False) | ||
non_active_user.save() | ||
|
||
# Get all users | ||
users = User.objects.all() | ||
|
||
# Count users | ||
users.count() | ||
|
||
# Get first user | ||
users.first() | ||
|
||
# Get last user | ||
users.last() | ||
|
||
# Filter users | ||
active_users = User.objects.filter(is_active=True) | ||
# Or | ||
active_users = User.objects.exclude(is_active=False) | ||
|
||
# Update all active users | ||
active_users.update(is_active=False) | ||
|
||
# Delete all non active users | ||
User.objects.exclude(is_active=True).delete() | ||
|
||
# Get one user and delete | ||
user = User.objects.get(name='John Doe') | ||
user.delete() | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
::: supadantic.models.BaseSBModel |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
::: supadantic.models.ModelMetaclass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
::: supadantic.q_set.QSet |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
site_name: Supadantic | ||
repo_url: https://github.com/makridenko/supadantic | ||
site_url: https://makridenko.github.com/supadantic | ||
site_description: Supadantic is a small Python library that allows you to manage Supabase tables through Pydantic models. It is very convenient to use in projects based on FastAPI, Flask, and so on. | ||
copyright: Maintained by <a href="https://github.com/makridenko/">Alexey Makridenko</a> | ||
|
||
nav: | ||
- Home: | ||
- Overview: index.md | ||
- Changelog: changelog.md | ||
- API Documentation: | ||
- Clients: | ||
- Base: | ||
- SingletoneMeta: clients/base/singletone_meta.md | ||
- BaseClient: clients/base/base.md | ||
- CacheClient: clients/cache.md | ||
- SupabaseClient: clients/supabase.md | ||
- Models: | ||
- BaseSBModel: | ||
- ModelMetaclass: models/model_metaclass.md | ||
- BaseSBModel: models/base_sb_model.md | ||
- QSet: q_set.md | ||
|
||
plugins: | ||
- search | ||
- mkdocstrings: | ||
handlers: | ||
python: | ||
options: | ||
docstring_style: google | ||
show_doctring_examples: true | ||
merge_init_into_class: true | ||
show_source: false | ||
docstring_options: | ||
ignore_init_summary: true | ||
separate_signature: true | ||
show_root_heading: true | ||
show_root_full_path: false | ||
show_signature_annotations: true | ||
show_symbol_type_heading: true | ||
show_symbol_type_toc: true | ||
signature_crossrefs: true | ||
summary: true | ||
|
||
theme: | ||
name: 'material' | ||
feature: | ||
tabs: true | ||
icon: | ||
repo: fontawesome/brands/github | ||
features: | ||
- announce.dismiss | ||
- content.action.edit | ||
- content.action.view | ||
- content.code.annotate | ||
- content.code.copy | ||
- content.tooltips | ||
- navigation.footer | ||
- navigation.indexes | ||
- navigation.sections | ||
- navigation.tabs | ||
- navigation.tabs.sticky | ||
- navigation.top | ||
- search.highlight | ||
- search.suggest | ||
- toc.follow | ||
palette: | ||
scheme: slate | ||
primary: black | ||
accent: lime | ||
|
||
extra: | ||
social: | ||
- icon: fontawesome/brands/github | ||
link: https://github.com/makridenko/supadantic | ||
- icon: fontawesome/brands/python | ||
link: https://pypi.org/project/supadantic/ | ||
|
||
markdown_extensions: | ||
- toc: | ||
permalink: true | ||
- pymdownx.arithmatex: | ||
generic: true | ||
- admonition | ||
- pymdownx.keys | ||
- pymdownx.magiclink | ||
- pymdownx.superfences: | ||
custom_fences: | ||
- name: mermaid | ||
class: mermaid | ||
- pymdownx.tasklist: | ||
custom_checkbox: true |
Oops, something went wrong.