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.0.tar.gz (18.4 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.0-py3-none-any.whl (25.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: sftkit-0.4.0.tar.gz
  • Upload date:
  • Size: 18.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.9 {"installer":{"name":"uv","version":"0.9.9"},"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.0.tar.gz
Algorithm Hash digest
SHA256 46e33dca2ebafd4eac76d653c3cbf4b35713dae20aa2706aea0e2436a74d3bb5
MD5 2ff3825a17628dc286b8cdddfa57a95d
BLAKE2b-256 deb71c34c7b937f6c32256ac07904ddcf9ec739b655cfe921412ab179030b785

See more details on using hashes here.

File details

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

File metadata

  • Download URL: sftkit-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 25.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.9 {"installer":{"name":"uv","version":"0.9.9"},"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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 834971d8c3bfa56cfd38d7d341fc8495aa039bb87d369624101d3f3bd7831f7f
MD5 b3ceb31f33ad4fe40154732da16fb78a
BLAKE2b-256 82ae45e7eb0c37a118e2e15fa7ec3dd90ecf99c469cbbefe97a049c8b3a88f38

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