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.1.tar.gz (18.6 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.1-py3-none-any.whl (25.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: sftkit-0.4.1.tar.gz
  • Upload date:
  • Size: 18.6 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.1.tar.gz
Algorithm Hash digest
SHA256 b185c8fa8bc02eb521699465f5797c4ebb4abcd8c49afef1e1742291b2661c7b
MD5 9b1ad95b74c5bf40783a3325a5454db0
BLAKE2b-256 7fc009711d27b42e4b269589193ed33d25fc357d5567465d92d69f714d4485ac

See more details on using hashes here.

File details

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

File metadata

  • Download URL: sftkit-0.4.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ceaeb8b7a03276c45da3c47b3ce38e77e3b94d63d07ea7b87e9ed87d970b05a9
MD5 43f3652264af6b84421dd00f1bf62506
BLAKE2b-256 82ad54992c05ce65ac07000af8bdf12441451189b9fa0c93eb4171160bb8933f

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