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.3.tar.gz (21.9 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.3-py3-none-any.whl (25.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: sftkit-0.3.3.tar.gz
  • Upload date:
  • Size: 21.9 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.3.tar.gz
Algorithm Hash digest
SHA256 b4e0cc0ec1e6713d4da9b8f453b732a4ed9ec55394b763cda1d8b6ca9d10cacb
MD5 f866f3bad2ed66bf7a25f833b89a30ad
BLAKE2b-256 2fd341c1553421771ab2b8498422585a3e9330f4b3033cbbdfbab488a6c2218f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: sftkit-0.3.3-py3-none-any.whl
  • Upload date:
  • Size: 25.0 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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 fd81ddbbd5f673628a9b60a34091aef3a70a88669f1180fdab1e549cef7a6946
MD5 6b2f01cc22aee00454f027bb75a65104
BLAKE2b-256 48a4403fc555bed6975a9535949ed7d73e5dc87f51fc7f7a3d7018b5f9d32b51

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