1+ # Create a database and a schema to hold the data to lookup.
12snow sql -q "
23CREATE DATABASE IF NOT EXISTS IP2LOCATION;
34CREATE SCHEMA IF NOT EXISTS IP2LOCATION;
45"
6+ # Create the table to host the data.
7+ # Create a file format for the file
8+ # Create a stage so we can upload the file
59
610snow sql -q "
711CREATE TABLE IF NOT EXISTS LITEDB11 (
@@ -27,22 +31,30 @@ COMPRESSION = AUTO;
2731CREATE STAGE IF NOT EXISTS IP2LOCATION.IP2LOCATION.LOCATION_DATA_STAGE
2832file_format = LOCATION_CSV;" --database ip2location --schema ip2location
2933
34+ # Copy the csv files from your local machine to the stage we created previously
3035snow stage copy /USER_PATH_HERE/IP2LOCATION-LITE-DB11.CSV @location_data_stage --database ip2location --schema ip2location
3136
37+ # Copy the csv file from the stage to load the table
3238snow sql -q "
3339copy into litedb11 from @location_data_stage
3440files = ('IP2LOCATION-LITE-DB11.CSV')
3541;" --database ip2location --schema ip2location
3642
43+ # Simple query test to ensure the table is correctly filled.
3744snow sql -q " SELECT COUNT(*) FROM LITEDB11;
3845SELECT * FROM LITEDB11 LIMIT 10;" --database ip2location --schema ip2location
3946
47+ # Create test database and schema.
4048snow sql -q " CREATE DATABASE IF NOT EXISTS TEST_IPLOCATION;
41- CREATE SCHEMA IF NOT EXISTS TEST_IPLOCATION;
49+ CREATE SCHEMA IF NOT EXISTS TEST_IPLOCATION;"
4250
51+ # Create test table to insert some values
52+ snow sql -q "
4353CREATE OR REPLACE TABLE TEST_IPLOCATION.TEST_IPLOCATION.TEST_DATA (
4454 IP VARCHAR(16),
4555 IP_DATA VARIANT
46- );
56+ );"
4757
48- INSERT INTO TEST_IPLOCATION.TEST_IPLOCATION.TEST_DATA(IP) VALUES('73.153.199.206'),('8.8.8.8');"
58+ # Insert testing values to use later on
59+ snow sql -q "
60+ INSERT INTO TEST_IPLOCATION.TEST_IPLOCATION.TEST_DATA(IP) VALUES('73.153.199.206'),('8.8.8.8');"
0 commit comments