Giter VIP home page Giter VIP logo

mysql-transfer's Introduction

mysql-transfer python module

This python module is for transferring MySQL databases.

Quick Start

Install mysql_transfer with pip install git+https://[email protected]/MichaelMackus/mysql-transfer.git.

Transferring a symfony site:

from contextlib import closing
import mysql_transfer

from_params = mysql_transfer.load_params('path/to/parameters.yml',
                           db_params={'host': 'database_host',
                                      'name': 'database_name',
                                      'user': 'database_user',
                                      'password': 'database_password',
                                      'port': 'database_port'},
                           param_key='parameters')

to_params = mysql_transfer.load_params('path/to/parameters.yml',
                           db_params={'host': 'database_host',
                                      'name': 'database_name',
                                      'user': 'database_user',
                                      'password': 'database_password',
                                      'port': 'database_port'},
                           param_key='parameters')


tables = [] # set list of tables to transfer - empty means *ALL*
mysql_transfer.transfer_db(from_params, to_params, tables)

To transfer a bolt site, use:

from contextlib import closing
import mysql_transfer

from_params = mysql_transfer.load_params('path/to/parameters.yml',
                           db_params={'host': 'host',
                                      'name': 'databasename',
                                      'user': 'username',
                                      'password': 'password',
                                      'port': 'port'},
                           param_key='database')

to_params = mysql_transfer.load_params('path/to/parameters.yml',
                           db_params={'host': 'host',
                                      'name': 'databasename',
                                      'user': 'username',
                                      'password': 'password',
                                      'port': 'port'},
                           param_key='database')


tables = [] # set list of tables to transfer - empty means *ALL*
mysql_transfer.transfer_db(from_params, to_params, tables)

To transfer via an SSH tunnel:

from contextlib import closing
from mysql_transfer import transfer_db
from mysql_transfer.mysql_params import Params, MySQLParams
from mysql_transfer.mysql_tunnel import open_tunnel, SSHParams

from_params = MySQLParams({'host': '127.0.0.1',
                    'name': 'db_name',
                    'user': 'user_name',
                    'password': 'password',
                    'port': '3307'})

to_params = MySQLParams({'host': '127.0.0.1',
                  'name': 'to_db_name',
                  'user': 'local_user_name',
                  'password': 'local_password'})

tables = [] # set list of tables to transfer - empty means *ALL*

# create our SSH tunnel, listening to remote-db.host.com:3306 on
# 127.0.0.1:3307, via SSH tunnel to ssh_host
with open_tunnel(SSHParams('ssh_host'),
                 Params('remote-db.host.com',
                        3306),
                 from_params):
    # do the transfer
    transfer_db(from_params, to_params, tables)

For more details, see help(mysql_transfer.load_params), help(mysql_transfer.MySQLParams), and help(mysql_transfer.transfer_db) in a python REPL (you'll have to import mysql_transfer first).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.