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>
Metadata
Release files for sftkit 0.4.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| sftkit-0.4.3.tar.gz | 18.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| sftkit-0.4.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 44.3 kB
Release files / sftkit-0.4.3.tar.gz
| Download URL | sftkit-0.4.3.tar.gz |
|---|---|
| Size | 18.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f982fedc66e15dade51159fcc2b961246cf3b3d417935a69739cf5be66fd3d56
|
|
BLAKE2b-256 checksum How to use checksums |
b620c8922da1a20d009d20fcd07120064476049d2cc141cbc452c39cdf89d442
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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}
|
Release files / sftkit-0.4.3-py3-none-any.whl
| Download URL | sftkit-0.4.3-py3-none-any.whl |
|---|---|
| Size | 25.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c024a7738a7c81e4f85a6912e995db878311afd49f4eeb36d9d25d5431dd81e3
|
|
BLAKE2b-256 checksum How to use checksums |
3fd66685c9cbca709bd7ff73c45ac554bf984c66e7cff6ebf2c20fe4f42f274b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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}
|