Skip to content

Commit

Permalink
SNOW-1344601-datamapping-repo-update (#2)
Browse files Browse the repository at this point in the history
minor changes to keep up with quickstart
  • Loading branch information
sfc-gh-ralfaroviquez authored Jun 17, 2024
1 parent 99adc82 commit bf088ca
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
1 change: 1 addition & 0 deletions data-mapping/app/manifest.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
manifest_version: 1
artifacts:
readme: README.md
setup_script: setup_script.sql
default_streamlit: ui."Dashboard"

Expand Down
18 changes: 15 additions & 3 deletions data-mapping/prepare_data.sh
Original file line number Diff line number Diff line change
@@ -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 (
Expand All @@ -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');"
2 changes: 1 addition & 1 deletion data-mapping/snowflake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ native_app:
dest: ./
package:
scripts:
- scripts/setup-package-script.sql
- scripts/setup_package_script.sql

0 comments on commit bf088ca

Please sign in to comment.