Skip to content

Latest commit

 

History

History
43 lines (37 loc) · 1.09 KB

sqlite.md

File metadata and controls

43 lines (37 loc) · 1.09 KB

SQLite

init db

sqlite3 -init db.sqlite

init db and import

# [pip3 install termsql](https://github.com/tobimensch/termsql)
termsql -i mycsvfile.CSV -d ',' -c 'field_name,field_index' -t 'index_de' -o mynewdatabase.db

create table and import

CREATE TABLE index_de(field_name TEXT NOT NULL, field_type TEXT NOT NULL );
CREATE TABLE index_cn(field_name TEXT NOT NULL, field_type TEXT NOT NULL );
-- show tables 
.tables
.schema index_cn

-- import csv to table 
.mode csv
.separator ","
.import autolabel-staging-merge.elk-index.cn.fields.csv index_cn
.import autolabel-merge.elk-index.de-prod.fields.csv index_de

sqlite export to file

.output autolabel-merge.fields
.shell ls -la autolabel-merge.fields
.shell cat autolabel-merge.fields

select index_cn.field_name, index_de.field_type "type_de", index_cn.field_type "type_cn"
from index_cn index_cn
inner join index_de on index_de.field_name=index_cn.field_name 
where index_cn.field_type != index_de.field_type
;
.output stdout
.exit