github
Advanced Search
  • Home
  • Pricing and Signup
  • Explore GitHub
  • Blog
  • Login

senorprogrammer / mysql2sqlite.rb

  • Admin
  • Watch Unwatch
  • Fork
  • Your Fork
  • Pull Request
  • Download Source
    • 8
    • 0
  • Source
  • Commits
  • Network (0)
  • Issues (0)
  • Downloads (0)
  • Wiki (1)
  • Graphs
  • Branch: master

click here to add a description

click here to add a homepage

  • Branches (1)
    • master ✓
  • Tags (0)
Sending Request…
Enable Donations

Pledgie Donations

Once activated, we'll place the following badge in your repository's detail box:
Pledgie_example
This service is courtesy of Pledgie.

A ruby script for exporting MySQL databases into Sqlite databases. — Read more

  cancel

  cancel
  • Private
  • Read-Only
  • HTTP Read-Only

This URL has Read+Write access

Passwords in the YAML config file are now optional 
senorprogrammer (author)
Fri May 29 11:25:48 -0700 2009
commit  814d5bb6a072f62dc753b4fe0fe9202f7b176d64
tree    a109689d31847dfb3e5323d8b2d99cf000d604fd
parent  f9a7b9169357231ae39b1ab5bad03a43f82f64e2
mysql2sqlite.rb /
name age
history
message
file .gitignore Mon Mar 02 05:37:33 -0800 2009 Now accepts YAML file for configuration; some m... [senorprogrammer]
file README Sun Mar 08 05:55:51 -0700 2009 Updated readme to include tables optional YAML ... [senorprogrammer]
file mysql2sqlite.rb Fri May 29 11:25:48 -0700 2009 Passwords in the YAML config file are now optional [senorprogrammer]
README
= mysql2sqlite.rb

== DESCRIPTION

A Ruby script to convert and export MySQL databases to Sqlite databases.


== USAGE

Can be executed by either passing the database connection values directly:

  ./mysql2sqlite.rb database_name database_user database_password

or by passing it the path to a YAML-based configuration file:

  ./mysql2sqlite.rb config.yaml


== OUTPUT

This script generates two files. The first is the raw SQL file derived from the MySQL database but after the 
Sqlite-specific modifications have been made to the SQL. This file is useful for debugging in the event that your MySQL 
database contains data that Sqlite doesn't like and this script doesn't catch (a scenario which should throw all sorts 
of errors to the console).

The second file is the Sqlite database itself, generated by passing the above-mentioned SQL file through sqlite3.


== YAML CONFIG FILE

If you're familiar with Rails or Merb, this format will seem uncanny:

  config:
    database: database_name
    username: database_username
    password: database_password


== OPTIONAL PARAMETERS

=== OVERWRITE

By default the script warns if if it is about to over-write already-existing files. However this can be explicitly 
configured via the following:

Command line: add "true" or "1" as the final parameter to over-write without warning:

  ./mysql2sqlite.rb database_name database_user database_password true

YAML file: add "true" as the 'overwrite' property to over-write without warning:

  config:
    database: database_name
    username: database_username
    password: database_password
    overwrite: true

=== TABLES

To explicitly specify which tables are to be output, add the table names to the YAML file:

  config:
    database: database_name
    username: database_username
    password: database_password
    overwrite: true
    tables:
      - users
      - messages
      - blog_posts
      
This parameter is not available via command-line configuration.


== KNOWN ISSUES

I know this is version 0.2 and thus I suspect it is inefficient as all get-out and likely fails on some databases (in 
other words: currently, it works for me). That said, it cleanly dumps the entire Rails app I needed it to dump and the 
Sqlite database seems just dandy. Give it a try, let me know.


== EXPECTED FUTURE FEATURES

- Better exception handling (actually, any exception handling at all). Right now it just chokes or steamrollers when it 
runs into a problem (like spelling your db password incorrectly).

- The ability to exclude the intermediary SQL file via configuration (or perhaps make it opt-in).


== LICENSE

(The MIT License)

Copyright (c) Chris Cummer 2009

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Blog | Support | Training | Contact | API | Status | Twitter | Help | Security
© 2010 GitHub Inc. All rights reserved. | Terms of Service | Privacy Policy
Powered by the Dedicated Servers and
Cloud Computing of Rackspace Hosting®
Dedicated Server