...
Project description
SFTKit
A general purpose collection of base building blocks and utilities to make building python applications on the basis of postgresql (asyncpg) + fastapi a breeze.
Getting Started
To get started simply run
pip install sftkit
A basic server could look like this
import asyncio
from dataclasses import dataclass
from sftkit.http import Server, HTTPServerConfig
from fastapi import APIRouter
config = HTTPServerConfig(base_url="/api/v1", port=8074, host="127.0.0.1")
router = APIRouter(
responses={404: {"description": "not found"}},
)
@router.get("/ping")
async def ping():
return "pong"
@dataclass
class Context:
config: HTTPServerConfig
class Api:
def __init__(self, config: HTTPServerConfig = config):
self.config = config
self.server = Server(
title="<your title>",
config=config,
license_name="<your license>",
version="0.1.0"
)
self.server.add_router(router)
async def run(self):
context = Context(config=self.config)
await self.server.run(context)
if __name__ == "__main__":
server = Api()
asyncio.run(server.run())
Copy the code to main.py and run the server using python main.py.
You can ping the server at http://127.0.0.1:8074/api/v1/ping or inspect the API specification at http://127.0.0.1:8074/api/v1/docs.
Usage
Dev CLI
Configure sftkit in your pyproject.toml
[tool.sftkit]
db_code_dir = "<path-to-your-sql-code-folder>"
db_migrations_dir = "<path-to-your-sql-data-migrations>"
Create new migrations via
sftkit create-migration <name>
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sftkit-0.4.3.tar.gz.
File metadata
- Download URL: sftkit-0.4.3.tar.gz
- Upload date:
- Size: 18.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.10.2 {"installer":{"name":"uv","version":"0.10.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f982fedc66e15dade51159fcc2b961246cf3b3d417935a69739cf5be66fd3d56
|
|
| MD5 |
efc8d58ff4a2422b073951bb6128d91e
|
|
| BLAKE2b-256 |
b620c8922da1a20d009d20fcd07120064476049d2cc141cbc452c39cdf89d442
|
File details
Details for the file sftkit-0.4.3-py3-none-any.whl.
File metadata
- Download URL: sftkit-0.4.3-py3-none-any.whl
- Upload date:
- Size: 25.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.10.2 {"installer":{"name":"uv","version":"0.10.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c024a7738a7c81e4f85a6912e995db878311afd49f4eeb36d9d25d5431dd81e3
|
|
| MD5 |
ea6e61c1d61072091428ac562bf8c73e
|
|
| BLAKE2b-256 |
3fd66685c9cbca709bd7ff73c45ac554bf984c66e7cff6ebf2c20fe4f42f274b
|