diff --git a/data-mapping/app/manifest.yml b/data-mapping/app/manifest.yml index afa02f5..e34e45e 100644 --- a/data-mapping/app/manifest.yml +++ b/data-mapping/app/manifest.yml @@ -1,5 +1,6 @@ manifest_version: 1 artifacts: + readme: README.md setup_script: setup_script.sql default_streamlit: ui."Dashboard" diff --git a/data-mapping/prepare_data.sh b/data-mapping/prepare_data.sh index a85d951..5dd9af2 100755 --- a/data-mapping/prepare_data.sh +++ b/data-mapping/prepare_data.sh @@ -1,7 +1,11 @@ +# Create a database and a schema to hold the data to lookup. snow sql -q " CREATE DATABASE IF NOT EXISTS IP2LOCATION; CREATE SCHEMA IF NOT EXISTS IP2LOCATION; " +# Create the table to host the data. +# Create a file format for the file +# Create a stage so we can upload the file snow sql -q " CREATE TABLE IF NOT EXISTS LITEDB11 ( @@ -27,22 +31,30 @@ COMPRESSION = AUTO; CREATE STAGE IF NOT EXISTS IP2LOCATION.IP2LOCATION.LOCATION_DATA_STAGE file_format = LOCATION_CSV;" --database ip2location --schema ip2location +# Copy the csv files from your local machine to the stage we created previously snow stage copy /USER_PATH_HERE/IP2LOCATION-LITE-DB11.CSV @location_data_stage --database ip2location --schema ip2location +# Copy the csv file from the stage to load the table snow sql -q " copy into litedb11 from @location_data_stage files = ('IP2LOCATION-LITE-DB11.CSV') ;" --database ip2location --schema ip2location +# Simple query test to ensure the table is correctly filled. snow sql -q "SELECT COUNT(*) FROM LITEDB11; SELECT * FROM LITEDB11 LIMIT 10;" --database ip2location --schema ip2location +# Create test database and schema. snow sql -q "CREATE DATABASE IF NOT EXISTS TEST_IPLOCATION; -CREATE SCHEMA IF NOT EXISTS TEST_IPLOCATION; +CREATE SCHEMA IF NOT EXISTS TEST_IPLOCATION;" +# Create test table to insert some values +snow sql -q " CREATE OR REPLACE TABLE TEST_IPLOCATION.TEST_IPLOCATION.TEST_DATA ( IP VARCHAR(16), IP_DATA VARIANT -); +);" -INSERT INTO TEST_IPLOCATION.TEST_IPLOCATION.TEST_DATA(IP) VALUES('73.153.199.206'),('8.8.8.8');" +# Insert testing values to use later on +snow sql -q " +INSERT INTO TEST_IPLOCATION.TEST_IPLOCATION.TEST_DATA(IP) VALUES('73.153.199.206'),('8.8.8.8');" \ No newline at end of file diff --git a/data-mapping/scripts/setup-package-script.sql b/data-mapping/scripts/setup_package_script.sql similarity index 100% rename from data-mapping/scripts/setup-package-script.sql rename to data-mapping/scripts/setup_package_script.sql diff --git a/data-mapping/snowflake.yml b/data-mapping/snowflake.yml index 8ddd289..057502b 100644 --- a/data-mapping/snowflake.yml +++ b/data-mapping/snowflake.yml @@ -7,4 +7,4 @@ native_app: dest: ./ package: scripts: - - scripts/setup-package-script.sql + - scripts/setup_package_script.sql