Skip to main content

swoop-db

The swoop database schema is managed via dbami, and uses dbami to implement a custom cli and python library for managing databases for swoop.

Installing swoop-db

swoop-db can be pip installed:

pip install swoop.db

If wanting to install locally for development purposes, see CONTRIBUTING.md for further instructions.

Postgres Extensions

swoop-db makes use of two postgres extensions:

  • pg_partman: an automated table partition manager
  • pgTap: a postgres-native testing framework

pgTap is only used for testing, and is not installed into the schema except when testing.

Database testing with docker

./Dockerfile defines the build steps for a database test container. The container includes the requsite postgres extensions. As the Dockerfile builds an image with all the database dependencies with fixed versions, using docker with that image is strongly recommended for all testing to help guarantee consistency between developers (running postgres in another way is fine if desired, but does require that the necessary extensions and utilities are installed, and that the connection information is correctly configured for tooling).

To make using the docker container more convenient, a docker-compose.yml file is provided in the project root. The repo contents are mounted as /swoop/db/ inside the container to help facilitate database operations and testing using the included utilities. For example, to bring up the database and run the tests:

# load the .env vars
source .env

# bring up the database container in the background
#   --build  forces rebuild of the container in case changes have been made
#   -V       recreates any volumes instead of reusing data
#   -d       run the composed images in daemon mode rather than in the foreground
docker compose up --build -V -d

# create the database and apply all migrations
swoop-db up

# connect to the database with psql
docker compose exec postgres psql -U postgres swoop

# create the database and load the schema.sql with a custom database name
swoop-db create --database swoop-custom
swoop-db load-schema --database swoop-custom

To verify the schema and migrations match:

# run the verification; any diff indicates schema/migrations out-of-sync
swoop-db verify

To drop a database:

# we'll drop the custom one we made earlier
swoop-db drop --database swoop-custom

To stop the postgres container:

docker compose down

The swoop-db cli is intended to be discoverable. When in doubt, try checking the help.

Metadata

Release files for swoop.db 8.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for swoop.db 8.0.3
File Size Uploaded
swoop.db-8.0.3.tar.gz 33.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for swoop.db 8.0.3
File Interpreter ABI Platform
swoop.db-8.0.3-py3-none-any.whl Python 3 none any Details

Total release size: 54.7 kB

Release files / swoop.db-8.0.3.tar.gz

Download URL swoop.db-8.0.3.tar.gz
Size 33.5 kB
Tags Source
SHA-256 checksum
How to use checksums
fa9bc05dad0591af804162daaa80f4f6a7e5584b925f686f164906beea2d132e
BLAKE2b-256 checksum
How to use checksums
58c07eac03444b1c0be995a9dd606ef71484fca198874cb4cdbc345d917c6703
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.17

Release files / swoop.db-8.0.3-py3-none-any.whl

Download URL swoop.db-8.0.3-py3-none-any.whl
Size 21.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a018d2dfb850131370171fa2972b391d7c35f6e8dabbd738aa7263ae70b95625
BLAKE2b-256 checksum
How to use checksums
0dcad47c5fc758c81969da87113d3c144c51dd23e940d3c366d9ad3b2ee3c2c6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.17

Release history Release notifications | RSS feed

This release

8.0.3 This release

2 release files

8.0.2

2 release files

8.0.1

2 release files

8.0.0

2 release files

7.0.3

2 release files

7.0.2

2 release files

7.0.1

2 release files

7.0.0

2 release files

2.0.0

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page