New Repo Who Dis


Query Then Run

A tool for querying multiple databases into sqlite and exporting a CSV out of it.

License: Proprietary


If you can write SQL; you can probably use this

Hacky: Done over a couple of nights.

WARNING: REQUIRES HARDCODING PASSWORDS: You'll need to include usernames and passwords into a SQL file temporarily. Not a great practice.

PRACTICAL: Beyond that, just write some queries.

Download Latest

Example: Select from Postgres, sqlite, csv and generate new CSV

In file "select-from-postgres.sql"
 
-- @driver.path= /tmp/postgresql-42.7.3.jar
-- @connection.vendor= postgresql
-- @connection.jdbc= jdbc:postgresql://192.168.1.1:5432/postgres?user=postgres&password=ThisIsMyPassword
-- @output.table_name= postgres_input
select id, first_name, first_name_inpg, gender, ip_address, air_country_code from mock_data_from_csv_inpg
            
In file "select-from-sqlite.sql"
 
-- @driver.path= /tmp/sqlite-jdbc-3.45.2.0.jar
-- @connection.vendor= sqlite
-- @connection.jdbc= jdbc:sqlite:/tmp/output-location/sqlite-output_11-04-2024_03-42-15.db
-- @output.table_name= sqlitetmp_table
select id, first_name, gender, ip_address, air_country_code from mock_data_from_csv
            
In file "select-from-csv.sql"
 
-- @driver.path= /tmp/sqlite-jdbc-3.45.2.0.jar
-- @connection.vendor= csv
-- @csv.filepath= /tmp/main_mock_data_from_csv_batches.csv
-- @csv.type= EXCEL
-- @csv.intermediary_sqlite_directory= /tmp/csv_sqlite_tmp
-- @csv.intermediary_table= intermediary_large_mock_csv
-- @output.table_name= mock_data_from_csv
select id, first_name, gender, ip_address, air_country_code from intermediary_large_mock_csv
            
In file "execute-final-query.sql"
 
-- @output.csv_name= output_selection1
select
    pg.id pg_id,
    sq.first_name sq_first_name,
    pg.first_name_inpg pg_first_name_inpg,
    csv.id csv_id
from
    postgres_input pg,
    sqlitetmp_table sq,
    mock_data_from_csv csv
where
    pg.id = sq.id
    and pg.first_name = sq.first_name
    and pg.id = csv.id
    and pg.first_name = csv.first_name
            
From the project root, and assuming all the files are above are in /tmp
 
./gradlew clean distZip
cd app/build/distributions
unzip app.zip -d app_unzip

app_unzip/app/include-in-dist/scripts/run-to-get-script-args.sh \
    -i "/tmp/select-from-sqlite.sql" \
    -i "/tmp/select-from-postgres.sql" \
    -i "/tmp/select-from-csv.sql" \
    -e "/tmp/execute-final-query.sql" \
    -o /tmp/output-location