Skip to content

Script to convert and add sqlite3 database into a mysql/mariadb database

License

Notifications You must be signed in to change notification settings

vwbusguy/sqlite-to-mysql

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 

Repository files navigation

sqlite-to-mysql

Script to convert and add sqlite3 database into a mysql/mariadb database

Description

This script is used to convert a sqlite3 .db file into a running mysql/mariadb 5.x+ instance. It was adapted from the code posted at http://www.redmine.org/boards/2/topics/12793?r=24999 . I've mostly simply altered it to make the effort of use minimal.

The script works as a layer between sqlite and mysql to format the sqlite dump, create a new user and database in mysql, and restore all the tables and data in one shell line.

Dependencies

A running flavor of MySQL (eg, MariaDB).

Python 2.7 / Python 3

Usage

$ sqlite3 filename.db .dump | ./sqlite3-to-mysql.py -u new_user -p new_password -d new_database | mysql -u root -p --default-character-set=utf8

That's it! Log into mysql database with your new user and your tables should be there and populated!

Notes

There isn't any forseeable reason for this not to work on Windows using sqlite.exe and mysql.exe, etc. I have not testing this.

As always, use your common sense and backup your data before attempting this. If you pick a database name that already exists in your mysql instance, expect the data to be overwritten.

Enjoy!

About

Script to convert and add sqlite3 database into a mysql/mariadb database

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages