Wrapper for importing CSV and Text files into MySQL and Postgress
Project description
SqlDbWrpr
| Category | Status' and Links |
|---|---|
| General | |
| CD/CI | |
| PyPI | |
| Github |
Overview
SqlDbWrpr is a Python-based utility designed to simplify interactions with SQL databases, specifically MySQL and MSSQL. It provides a high-level abstraction for common database operations, making it easier to manage database schemas, import/export data, and handle user permissions.
Key Features
- Schema Management: Define your database structure (tables, fields, types, primary keys, foreign keys, and indexes) using a simple Python dictionary. SqlDbWrpr handles the creation of the database and tables based on this definition.
- Data Import/Export:
- Effortlessly import data from CSV files into your SQL tables. It supports both single and multi-volume CSV files and handles data type conversions and date formatting.
- Export table data or custom SQL query results back to CSV files, with options for multi-volume exports if the data size is large.
- User and Permission Management: Create and delete database users and grant them specific rights across the database.
- SSL Support: Secure your database connections with built-in support for SSL CA, key, and certificate files.
- Batch Processing: Optimize performance during data imports with configurable batch sizes.
- Multi-Database Support: Includes dedicated classes for MySQL and MSSQL, ensuring compatibility across different SQL environments.
Installation
pip install SqlDbWrpr
Quick Start
from sqldbwrpr.sqldbwrpr import MySQL
# Define your database structure
db_structure = {
"Users": {
"ID": {
"Type": ["int"],
"Params": {"PrimaryKey": ["Y", "A"], "NN": "Y", "AI": "Y"},
},
"Username": {"Type": ["varchar", 50], "Params": {"NN": "Y"}},
"Email": {"Type": ["varchar", 100], "Params": {"NN": "Y"}},
}
}
# Initialize the wrapper
db = MySQL(
p_host_name="localhost",
p_user_name="root",
p_password="yourpassword",
p_db_name="my_database",
p_db_structure=db_structure,
p_recreate_db=True,
)
# Import data from CSV
db.import_csv("Users", "users_data.csv")
# Export data to CSV
db.export_to_csv("exported_users.csv", "Users")
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sqldbwrpr-5.0.1.tar.gz.
File metadata
- Download URL: sqldbwrpr-5.0.1.tar.gz
- Upload date:
- Size: 17.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.2.1 CPython/3.13.11 Linux/6.11.0-1018-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a2ed22d854ebdebf299e2a5c595338b4f96a758321c9270053eca4395902e4b6
|
|
| MD5 |
14905099a3a4e44fcafd11360b6f1a02
|
|
| BLAKE2b-256 |
d4fc4e6ed533638931524cf10f4df2cd09a0bc6a4f2ebaa019f1eb88a49c6ec8
|
File details
Details for the file sqldbwrpr-5.0.1-py3-none-any.whl.
File metadata
- Download URL: sqldbwrpr-5.0.1-py3-none-any.whl
- Upload date:
- Size: 15.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.2.1 CPython/3.13.11 Linux/6.11.0-1018-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7d20aed9204068dcda279a84084eaf87353d649823fa6d1ef9460c9faa0059ce
|
|
| MD5 |
851944ce7942f585d95b8451236094d8
|
|
| BLAKE2b-256 |
83d83cc605102a3a027cb5be610cfd6d151298b4945a26a57929ef0994469cde
|