Created
July 30, 2013 15:03
-
-
Save maligree/6113756 to your computer and use it in GitHub Desktop.
How it happened.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# open up the DB in the console | |
$ sqlite3 storage/regroup.db | |
# set output mode to `insert`, this returns SQL | |
sqlite3> .mode insert | |
# set output to file | |
sqlite3> .out /home/jacek/apps.sql | |
# run the query, effectively creating an SQL dump of the data | |
sqlite3> select * from apps; | |
# change output file (required, see sed lines) | |
sqlite3> .out /home/jacek/resources.sql | |
# rinse, repeat | |
sqlite3> select * from resources; | |
# say goodbye | |
sqlite3> .exit | |
# go home.. | |
cd /home/jacek | |
# sqlite doesn't include the real table name in the queries.. it prints "table" | |
# so we replace every occurence of "table" with the respective table name | |
sed -i 's/table/apps/g' apps.sql | |
sed -i 's/table/resources/g' resources.sql | |
# connect a console to MySQL | |
mysql -u regroup -p regroup | |
Enter password: | |
# use the source, Luke | |
mysql> source /home/jacek/apps.sql | |
# The ERRORs are OK. Duplicates are ignored, and come from migrations. | |
ERROR 1062 (23000): Duplicate entry '1' for key 'PRIMARY' | |
ERROR 1062 (23000): Duplicate entry '2' for key 'PRIMARY' | |
ERROR 1062 (23000): Duplicate entry '3' for key 'PRIMARY' | |
Query OK, 1 row affected (0.01 sec) | |
# one more time | |
mysql> source /home/jacek/resources.sql | |
ERROR 1062 (23000): Duplicate entry '1' for key 'PRIMARY' | |
ERROR 1062 (23000): Duplicate entry '2' for key 'PRIMARY' | |
ERROR 1062 (23000): Duplicate entry '3' for key 'PRIMARY' | |
ERROR 1062 (23000): Duplicate entry '4' for key 'PRIMARY' | |
Query OK, 1 row affected (0.00 sec) | |
Query OK, 1 row affected (0.01 sec) | |
Query OK, 1 row affected (0.00 sec) | |
... | |
Query OK, 1 row affected (0.00 sec) | |
# say goodbye as well | |
mysql> \q | |
$ | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment