Skip to main content

Database setup utilities with configuration handling

Project description

Database Setup Package

database_setup is a Python package designed to streamline database configuration and initialization. It supports YAML-based configuration files, database connection pooling, and utility functions for database management.

Features

  • Load database configurations from YAML files.
  • Create databases if they do not exist.
  • Execute schema and seed SQL files.
  • Insert default admin user with encrypted credentials.
  • Utilize connection pooling for optimized performance.

Installation

Install the package via pip:

pip3 install database_setup

Usage

Import the Package

from database_setup import setup_database

Setting Up a Database

Ensure your project directory contains a config/database.yml file with the following structure:

development:
  host: "localhost"
  port: 3306
  username: "root"
  password: "password"
  database: "example_db"
  autocommit: True
  blocking: True
  maxconnections: 5

Ensure the config folder contains schema.sql and seed.sql files for database schema and initial data.

Run the setup_database function:

setup_database('/path/to/project')

Replace /path/to/project with the absolute path to your project directory.

Example Database Configuration File config/database.yml:

development:
  host: "localhost"
  port: 3306
  username: "root"
  password: "password"
  database: "example_db"
  autocommit: True
  blocking: True
  maxconnections: 5

Example Schema File config/schema.sql:

CREATE TABLE IF NOT EXISTS User (
    id INT AUTO_INCREMENT PRIMARY KEY,
    user_type VARCHAR(50),
    name VARCHAR(100),
    username VARCHAR(50) UNIQUE,
    email VARCHAR(100),
    mobile VARCHAR(15),
    password TEXT,
    user_access TINYINT
);

Example Seed File config/seed.sql:

INSERT INTO User (user_type, name, username, email, mobile, password, user_access)
VALUES ('admin', 'Default Admin', 'admin', 'info@yun.buzz', '8888888888', '<encrypted_password>', 1);

Dependencies

This package depends on the following libraries:

  • pymysql
  • dbutils
  • PyYAML

License

This package is proprietary software and is distributed under the terms of the Proprietary License. Unauthorized redistribution or modification is prohibited. See the LICENSE file for more information.

Support

For inquiries or support contact: Neudeep Technologies Pvt Ltd

📧 neudeep.tech.pvt.ltd@gmail.com

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

database_setup-0.0.3.tar.gz (4.0 kB view details)

Uploaded Source

Built Distribution

database_setup-0.0.3-py3-none-any.whl (2.3 kB view details)

Uploaded Python 3

File details

Details for the file database_setup-0.0.3.tar.gz.

File metadata

  • Download URL: database_setup-0.0.3.tar.gz
  • Upload date:
  • Size: 4.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.12

File hashes

Hashes for database_setup-0.0.3.tar.gz
Algorithm Hash digest
SHA256 6641298c87f606cb1609dd76777493f18a76f12ab59aaac84efe6e97c0020d6c
MD5 e9ca35e1c20c9483fb0bf85612852723
BLAKE2b-256 21f59ef11bafc647b3fbd75e69e57757c6588c660c6b99411db24d05b84bb084

See more details on using hashes here.

File details

Details for the file database_setup-0.0.3-py3-none-any.whl.

File metadata

File hashes

Hashes for database_setup-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 a716c0dad6a9ccb00432a54195bc2e361942daabe455efdb6aaa0a575b056ad5
MD5 692a873887006bd724f330e0890330c4
BLAKE2b-256 7d2ece44478c28f78037f31437fca3059db9a722b90034065cff1471540d2b2e

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