Skip to main content

A package to transfer data between SQL databases like PostgreSQL, MySQL, MSSQL.

Project description

db2db

db2db is a Python package for transferring data between different SQL databases. It supports various database types including PostgreSQL, MySQL, and Microsoft SQL Server.

Features

  • Data Transfer: Transfer data between different SQL databases.
  • Supports Multiple Databases: Includes support for PostgreSQL, MySQL, and MSSQL.
  • Simple Interface: Easy-to-use API for database operations.

Installation

You can install db2db from PyPI using pip:

pip install db2db

Usage

Here is a basic example of how to use db2db to transfer data between two databases.

Example

1.Create a configuration for your source and target databases:

source_db_config = {
    'db_type': 'postgresql',
    'host': 'localhost',
    'database': 'source_db',
    'user': 'your_user',
    'password': 'your_password'
    }

target_db_config = {
    'db_type': 'mysql', 
    'host': 'localhost', 
    'database': 'target_db'  
    'user': 'your_user', 
    'password': 'your_password'`
    }

2.Perform data transfer:

from db2db import transfer_data  
source_table = 'source_table_name'` 
target_table = 'target_table_name'

try:` 
    transfer_data(source_db_config, target_db_config, source_table, target_table) 
    print("Data transfer completed successfully.")  
except Exception as e:` 
    print(f"An error occurred: {e}")

Configuration

Supported Databases

  • PostgreSQL
  • MySQL
  • MSSQL

Connection String Configuration

The create_connection_string function in db2db.utils helps generate the connection string based on the database type and configuration parameters.

Example Configuration

def create_connection_string(db_type, **kwargs): 
    """
    Create a SQLAlchemy connection string.

    Parameters:  
    - db_type (str): Type of database ('postgresql', 'mysql', 'mssql'). 
    - kwargs (dict): Additional parameters for database connection.

    Returns:  
    - str: SQLAlchemy connection string.  
    """  
    pass  # Implement your function here

Testing

To run tests, use the following commands:

1.Set up the environment:

python -m venv venv  
source venv/bin/activate  # or venv\Scripts\activate on Windows  
pip install -r requirements.txt

2.Run the tests:

python -m unittest discover -s tests

Contributing

Contributions are welcome! Please follow these steps to contribute:

  1. Fork the repository.
  2. Create a new branch.
  3. Make your changes.
  4. Submit a pull request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

About Me

I am Akhtar Raza, a Team Lead Software Developer working at Fin Rise Softech Pvt Ltd. I am passionate about creating efficient software solutions and enjoy working on innovative projects.

Contact

For any questions or issues, please contact me at akhtar.decy@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

db2db_2-0.1.0.tar.gz (4.7 kB view details)

Uploaded Source

Built Distribution

db2db_2-0.1.0-py3-none-any.whl (7.5 kB view details)

Uploaded Python 3

File details

Details for the file db2db_2-0.1.0.tar.gz.

File metadata

  • Download URL: db2db_2-0.1.0.tar.gz
  • Upload date:
  • Size: 4.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.3

File hashes

Hashes for db2db_2-0.1.0.tar.gz
Algorithm Hash digest
SHA256 0852adb78468b1651090185c9cf711cc6c9e13ae798c4ce886ca5a4df1188fc4
MD5 0dbf9b7832a74ceddfa59360942093b4
BLAKE2b-256 5afcd72fdfb8da8ce1f7522ae744281d6cc82c83935c75f5e9dc158deb283264

See more details on using hashes here.

File details

Details for the file db2db_2-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: db2db_2-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 7.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.3

File hashes

Hashes for db2db_2-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b9c0fa68342bd0514b88d66ec373fe27a3ace5044587a90073b1394932de0351
MD5 3ad2c762a5c506bf2c9974600086b493
BLAKE2b-256 203396695cc9b55e8945f771b50ec58fa54b255cee6c534f8b08a48d88e00b69

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