fundamentals.mysql.sqlite2mysql

Take a sqlite database file and copy the tables within it to a MySQL database

Usage: sqlite2mysql -s []

Options:

pathToSqliteDB        path to the sqlite database file
tablePrefix           a string to prefix the table names when copying to mysql database
pathToSettingsFile    path to a settings file with logging and database information (yaml file)

-h, --help            show this help message
-v, --version         show version
-s, --settings        the settings file

Module Contents

Classes

sqlite2mysql

Take a sqlite database file and copy the tables within it to a MySQL database

Functions

main

The main function used when yaml_to_database.py when installed as a cl tool

API

fundamentals.mysql.sqlite2mysql.main(arguments=None)[source][source]

The main function used when yaml_to_database.py when installed as a cl tool

class fundamentals.mysql.sqlite2mysql.sqlite2mysql(log, pathToSqlite, tablePrefix='', settings=False, dbConn=False)[source][source]

Bases: object

Take a sqlite database file and copy the tables within it to a MySQL database

Key Arguments

  • log – logger

  • settings – the settings dictionary

  • pathToSqlite – path to the sqlite database to transfer into the MySQL database

  • tablePrefix – a prefix to add to all the tablename when converting to mysql. Default “”

  • dbConn – mysql database connection

Usage

To setup your logger, settings and database connections, please use the fundamentals package (see tutorial here https://fundamentals.readthedocs.io/en/master/initialisation.html).

To convert and import the content of a sqlite database into MySQL run the following:

… todo::

- add a tutorial about ``sqlite2mysql`` to documentation
from fundamentals.mysql import sqlite2mysql
converter = sqlite2mysql(
    log=log,
    settings=settings,
    pathToSqlite="/path/to/sqlite.db",
    tablePrefix="external"
)
converter.convert_sqlite_to_mysql()

Initialization

convert_sqlite_to_mysql()[source][source]

copy the contents of the sqlite database into the mysql database

See class docstring for usage