Skip to main content

statikk is a single table application (STA) library for DynamoDb.

Project description

Statikk

We built this library because we got fed up with all the boilerplate we needed to write to use DynamoDB in a Single Table Application architecture. We were originally using PynamoDB , but we found it to be too verbose for our liking.

This library is very much in alpha phase and is not yet recommended for production use. We are actively working on it and using it as a core library for our upcoming game, Conquests of Ethoas. Drastic API changes can still happen.

Requirements

  • Pydantic 2.3+

  • Python 3.8+

Probably works on older versions of Python, but we haven’t tested it.

Installation

pip install statikk

Basic Usage

from statikk.models import DatabaseModel, Table, GlobalSecondaryIndex, KeySchema, IndexPrimaryKeyField, IndexSecondaryKeyField

class MyAwesomeModel(DatabaseModel):
  player_id: IndexPrimaryKeyField
  tier: IndexSecondaryKeyField
  name: str = "Foo"
  values: set = {1, 2, 3, 4}
  cost: int = 4

table = Table(
  name="my-dynamodb-table",
  key_schema=KeySchema(hash_key="id"),
  indexes=[
    GSI(
      name="main-index",
      hash_key=Key(name="gsi_pk"),
      sort_key=Key(name="gsi_sk"),
     )
   ],
  models=[MyAwesomeModel],
)

def main():
  my_model = MyAwesomeModel(id="foo", player_id="123", tier="gold")
  my_model.save()
  MyAwesomeModel.update("foo").set(name="Bar").delete("values", {1}).add("cost", 1).execute() # Update multiple fields at once
  my_model = table.get("foo", MyAwesomeModel) # Get a model by its primary key using the table
  my_model = MyAwesomeModel.get("foo") # Get a model by its primary key using the model's class
  my_model.gsi_pk # returns "123"
  my_model.gsi_sk # returns "MyAwesomeModel|gold"
  my_model.delete() # Delete a model

See the usage docs for more

Features

  • Single Table Application architecture

  • Easy model definition using Pydantic

  • Automatic index value construction based on marked fields.

  • Get, Update, Delete, Batch Get, Batch Write, Query, and Scan operations

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

statikk-0.0.12.tar.gz (62.0 kB view details)

Uploaded Source

Built Distribution

statikk-0.0.12-py3-none-any.whl (15.3 kB view details)

Uploaded Python 3

File details

Details for the file statikk-0.0.12.tar.gz.

File metadata

  • Download URL: statikk-0.0.12.tar.gz
  • Upload date:
  • Size: 62.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.12.0

File hashes

Hashes for statikk-0.0.12.tar.gz
Algorithm Hash digest
SHA256 9f0292bbef29265d07cab56efe2dac8baabdec3765a46e63bfcbaa6760b4b9d0
MD5 f493519cc737690a6920c5b1ea4e22a4
BLAKE2b-256 910f00efa0ba57bb54522afe76ef08609d50f5ff16d046067415df7ccab25148

See more details on using hashes here.

File details

Details for the file statikk-0.0.12-py3-none-any.whl.

File metadata

  • Download URL: statikk-0.0.12-py3-none-any.whl
  • Upload date:
  • Size: 15.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.12.0

File hashes

Hashes for statikk-0.0.12-py3-none-any.whl
Algorithm Hash digest
SHA256 238d5a9deb204cc40388e7886cfd6ff67762831e7cedc2954a68ad3ae72f7142
MD5 5fc6be6d59f93d60535ec4dfdd46336d
BLAKE2b-256 6af4fca7013a8fcd7f32db02833534dc5f86bba366575e7d548878dc4ef8ffa0

See more details on using hashes here.

Supported by

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