Skip to main content

No project description provided

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.3.2.tar.gz (21.8 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.3.2-py3-none-any.whl (24.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: sftkit-0.3.2.tar.gz
  • Upload date:
  • Size: 21.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: pdm/2.24.2 CPython/3.12.3 Linux/6.11.0-1014-azure

File hashes

Hashes for sftkit-0.3.2.tar.gz
Algorithm Hash digest
SHA256 3e11b3e4b14a77b96cd67198a8b53626744b0ac1dadcdd718fa8ea0cc8d3e68c
MD5 d8fd9aad23b72c4a7c0702e2288b35c4
BLAKE2b-256 a9b275557f1e590918ead49bcd3a7ade0fc3dbc9c36ed6062d950fdc89a2fd94

See more details on using hashes here.

File details

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

File metadata

  • Download URL: sftkit-0.3.2-py3-none-any.whl
  • Upload date:
  • Size: 24.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: pdm/2.24.2 CPython/3.12.3 Linux/6.11.0-1014-azure

File hashes

Hashes for sftkit-0.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 660297a6b36507b3cf75bef19ff77b0be78ffeef85929c7fb16fcb6251d80e61
MD5 c5029e4e8069855969963a446ebf4b78
BLAKE2b-256 19522a9db5705bf93dc531a983c43aba3f5fc17cbcfce22c888b49e401bc4eba

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