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.4.tar.gz (2.3 kB view details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: database_setup-0.0.4.tar.gz
  • Upload date:
  • Size: 2.3 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.4.tar.gz
Algorithm Hash digest
SHA256 d2392bff434a2572e510207e92e338431cfde1a3ec115c8394374e9ea06426fc
MD5 806c460c0c966b2997ada53542376c4c
BLAKE2b-256 84f81e420f571f899b83354935639ff0390a052ee3a0ea14b8481f40622b8e40

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for database_setup-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 bb1453756342657882834300e90d9bd7dd39477aea2b913f273cb14684d58e10
MD5 aaabc9587e4578d94dcb708a0d4a89f3
BLAKE2b-256 64353bdaac81c1ea1733a415b1f76b1f66fd1bb09ad08e008e5af489ed326500

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