Skip to main content

Database Versioner (dbv)

Database versioner to be used to version Postgres & Redshift

Features

  • Able to run db migrations in a single command
  • Manages current version of the database
  • Able to randomize password and store in AWS SSM
  • Useful for CICD deployments
  • Better than sharing data dump exports

Installation

This is a python module available through the pypi registry.

Before installing, download and install python. python 3 or higher is required.

Installation is done using the pip install command:

$ pip install syngenta_digital_dbv

or

$ pipenv install syngenta_digital_dbv

Basic Usage

Postgres/Redshift

import syngenta_digital_dbv

def some_func():
    syngenta_digital_dbv.version(
        engine='postgres',
        endpoint='localhost',
        database='dbv-postgis',
        port=5433,
        user='root',
        password='Lq4nKg&&TRhHv%7z',
        ssm_param='local-postgres-config',
        versions_directory='application/db_versions/version_number_files',
        reset_root=True
    )
Option Name Required Type Description
engine true string name of supported db engine (postgres)
endpoint true string url of your host db
database true string name of the database to connect to
port true int port of database (no defaults)
user true string root username for database access
password true string root password for database access
versions_directory true string directory where all you files can be found
ssm_param false string ssm param path you want to store your db configs
reset_root false boolean whether to reset the root password; will ignore if ssm_param not defined
seed false boolean whether to seed data (great for local development)
seed_directory false string directory where all you files can be found

Postgres/Redshift Example File Contents

CREATE TABLE users_a (
    id SERIAL PRIMARY KEY,
    "user" text,
    password text
);
CREATE TABLE foods_a (
    id SERIAL PRIMARY KEY,
    name text,
    calories text
);
ALTER TABLE foods_a ADD COLUMN user_id int;
ALTER TABLE foods_a ADD CONSTRAINT user_id FOREIGN KEY (user_id) REFERENCES users_a (id) MATCH FULL;

NOTE: File names must be unique and in order (i.e. 1.sql, 2.sql, etc or a.sql, b.sql, etc), this is how the package knows what order to run the files in

Mongo

import syngenta_digital_dbv

def some_func():
    syngenta_digital_dbv.version(
        engine='mongo',
        database='unit',
        user='root',
        password='Lq4nKg&&TRhHv%7z',
        endpoint='mongodb://localhost:27017/',
        versions_directory='tests/mocks/mongo/version_number_files',
        seed=True,
        seed_directory='tests/mocks/mongo/seed'
    )
Option Name Required Type Description
engine true string name of supported db engine (postgres)
endpoint true string url of your host db
database true string name of the database to connect to
user true string root username for database access
password true string root password for database access
versions_directory true string directory where all you files can be found
seed false boolean whether to seed data (great for local development)
seed_directory false string directory where all you files can be found

Mongo Example File Contents

[
    {
        "database": "unit",
        "collection": "test",
        "operation": "create_index",
        "query": "user_email",
        "params": {"background": true, "unique": true}
    },
    {
        "database": "unit",
        "collection": "test",
        "operation": "create_index",
        "query": [["first", 1], ["last", -1]],
        "params": {"name": "first_last"}
    }
]

NOTE: Full list of collection operations found here: https://pymongo.readthedocs.io/en/stable/api/pymongo/collection.html

NOTE: Databases and collections are automatically by mongo; no need to have specific commands to create them

NOTE: File names must be unique and in order (i.e. 1.json, 2.json, etc or a.json, b.json, etc), this is how the package knows what order to run the files in

Metadata

Release files for syngenta-digital-dbv 0.0.9

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

Source distribution (sdist)

Source distribution for syngenta-digital-dbv 0.0.9
File Size Uploaded Provenance Actions
syngenta_digital_dbv-0.0.9.tar.gz 12.6 kB Without provenance Details for syngenta_digital_dbv-0.0.9.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for syngenta-digital-dbv 0.0.9
File Interpreter ABI Platform Actions
syngenta_digital_dbv-0.0.9-py3-none-any.whl Python 3 none any Details for syngenta_digital_dbv-0.0.9-py3-none-any.whl

Total release size: 26.7 kB

Release files / syngenta_digital_dbv-0.0.9.tar.gz

Download URL syngenta_digital_dbv-0.0.9.tar.gz
Size 12.6 kB
Tags Source
SHA-256 checksum
How to use checksums
a1fcf7950f8fc32aa0d47bfb6b12aa07ddf79a7a3b8e4f88f9de46d350234e2f
BLAKE2b-256 checksum
How to use checksums
418a857e402736ff9d5488c37eba49f50c2a6b55ed53b8c00db820da57cd7731
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.8.6

Release files / syngenta_digital_dbv-0.0.9-py3-none-any.whl

Download URL syngenta_digital_dbv-0.0.9-py3-none-any.whl
Size 14.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e6198f1a695ccd86b41a803210ecd0a58b6e4cfb019638a24a60aefed1f253d1
BLAKE2b-256 checksum
How to use checksums
2385f0c791f1919523f676a87b3440c55d0d5e8533e33fce324c9330ab28175c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.8.6

Security for syngenta-digital-dbv 0.0.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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