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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file database_setup-0.0.5.tar.gz
.
File metadata
- Download URL: database_setup-0.0.5.tar.gz
- Upload date:
- Size: 2.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d24bc47967af4ee686ec3df20b90a0f6dc94d75c61e9b79d1a3e450b2394fdac |
|
MD5 | 157235c9df42a7e35b10ff47613b8dfb |
|
BLAKE2b-256 | 67d3d74e6b1d97facea34eb894b7bffa7e7328383af611a391a9168f54123018 |
File details
Details for the file database_setup-0.0.5-py3-none-any.whl
.
File metadata
- Download URL: database_setup-0.0.5-py3-none-any.whl
- Upload date:
- Size: 2.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 631efa420a9d848a5c3b2c8a668c58f53083349fa5e036ef71664f6acfd71010 |
|
MD5 | 3f28386cdf99220fe253c3f01081ec81 |
|
BLAKE2b-256 | 350ad8f6049c712a196032d8723ccc8b067d5a8c5a3ad48d0f89f17e49e1fd88 |