Skip to main content

...

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sftkit-0.4.2.tar.gz (18.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sftkit-0.4.2-py3-none-any.whl (25.8 kB view details)

Uploaded Python 3

File details

Details for the file sftkit-0.4.2.tar.gz.

File metadata

  • Download URL: sftkit-0.4.2.tar.gz
  • Upload date:
  • Size: 18.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","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

Hashes for sftkit-0.4.2.tar.gz
Algorithm Hash digest
SHA256 763fab57af6553b2f325a3464ec8b4c137e0d6dc8dc48ec9f0129fde25107d8c
MD5 78dafad8cc6427fb955f47f89b79a301
BLAKE2b-256 29df24ba78dd2f038ca1d210c41c4e2704979cc94d80e1c3fd8ccab86829da64

See more details on using hashes here.

File details

Details for the file sftkit-0.4.2-py3-none-any.whl.

File metadata

  • Download URL: sftkit-0.4.2-py3-none-any.whl
  • Upload date:
  • Size: 25.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","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

Hashes for sftkit-0.4.2-py3-none-any.whl
Algorithm Hash digest
SHA256 6bb240594502cd0e33cb860c3d8d4798867aca9dfec1773b8e72c9aa0add107e
MD5 a10994782e5b716e9ec47140fc6fe4c6
BLAKE2b-256 3687e0ba1f22cacc299bee61c7f91c1cd94e365bec584f711fb45c621d186d74

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page