Last active
August 29, 2015 14:04
-
-
Save ffabreti/1bdd6ade847913c74a23 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
------------------------------------------------------- | |
copy table FROM SHELL between distinct database files: | |
-------------------------------------------------------- | |
sqlite3 source.sqlite3 ".schema myTable" | sqlite3 destination.sqlite3 | |
sqlite3 source.sqlite3 "SELECT * FROM myTable" | sqlite3 destination.sqlite3 ".import /dev/stdin myTable" | |
--------------------------------------------- | |
import data into table: | |
--------------------------------------------- | |
$ head cbo_ocupacoes.csv | |
"010105";"Oficial general da aeronáutica" | |
"010110";"Oficial general do exército" | |
"010115";"Oficial general da marinha" | |
"010205";"Oficial da aeronáutica" | |
"010210";"Oficial do exército" | |
"010215";"Oficial da marinha" | |
$ sqlite3 ../db/production.sqlite3 | |
sqlite> .separator ; | |
sqlite> .schema cbos | |
CREATE TABLE "cbos" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "codigo" varchar(255), "titulo" varchar(255), "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL); | |
sqlite> drop table cbos; | |
sqlite> CREATE TABLE "cbos" ( "codigo" varchar(255), "titulo" varchar(255) ); | |
sqlite> .import cbo_ocupacoes.csv cbos | |
--------------------------------------------- | |
dump table into file: | |
--------------------------------------------- | |
sqlite> .out cbos.dump.sql | |
sqlite> .dump cbos | |
--------------------------------------------- | |
read a sql file as commands to execute: | |
--------------------------------------------- | |
sqlite> .read commands.sql | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment