Sunday, May 1, 2016

execute sqlite commands within dockerfile

Leave a Comment

This dockerfile is working correctly. But how do I execute commands within dockerfile?

FROM alpine  RUN apk add --update sqlite && rm -rf /var/cache/apk/* RUN apk add --update wget && rm -rf /var/cache/apk/* RUN wget --no-check-certificate https://cdn.rawgit.com/times/data/master/sunday_times_panama_data.zip RUN unzip sunday_times_panama_data.zip 

But the next part needs to be executed at sqlite prompt. How do I declare this part?

# sqlite commands: sqlite3 sundayTimesPanamaPapers.sqlite .mode csv CREATE TABLE panama(company_url TEXT,company_name TEXT,officer_position_es TEXT,officer_position_en TEXT,officer_name TEXT,inc_date TEXT,dissolved_date TEXT,updated_date TEXT,company_type TEXT,mf_link TEXT); .import sunday_times_panama_data.csv panama 

1 Answers

Answers 1

Just feed it the commands using a pipe:

RUN echo '.mode csv\nCREATE TABLE panama(company_url TEXT,company_name TEXT,officer_position_es TEXT,officer_position_en TEXT,officer_name TEXT,inc_date TEXT,dissolved_date TEXT,updated_date TEXT,company_type TEXT,mf_link TEXT);\n.import sunday_times_panama_data.csv panama' | sqlite3 sundayTimesPanamaPapers.sqlite 
If You Enjoyed This, Take 5 Seconds To Share It

0 comments:

Post a Comment