Access the Live Snowflake Marketplace Data in Oracle Database
What is Snowflake Data Marketplace?
The benefits of Snowflake Data Marketplace:
- No data movement - Consumers are not required to copy the data, data is stored in provider accounts.
- Ready to query data - Consumers can immediately start querying data without
- transformation.
- Discover a variety of data - Consumers can search for a variety of data -Finance, Marketing, Health and Life Sciences, Sports, Travel, Lookup tables, etc.
- Live access - Receive real-time automatic updates.
- Reduce cost - Eliminates the costs and delays associated with the traditional ETL processes of data loading and transformation
Steps to access the Live Snowflake Marketplace Data in the Oracle Database
Architecture Diagram:
Here are the steps to access the Snowflake Marketplace data in Oracle 19c database running on Linux server.
1. Login to Snowflake website and search for the required data sources in Snowflake Data MarketplaceFor this demo, accessing the zip code data from Marketplace and named this share as
- Execute the following command to verify whether unixODBC is installed.
[root@localhost etc]# which odbcinst/usr/bin/which: no odbcinst in (/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin)[root@localhost etc]# which isql/usr/bin/which: no isql in (/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin)
- If unixODBC is not installed, as root execute the following commands:
# yum install unixODBC.x86_64Installed:unixODBC.x86_64 0:2.3.1-14.0.1.el7Complete!
- Verify the unixODBC installation:
[root@localhost etc]# which odbcinst/bin/odbcinst[root@localhost etc]# which isql/bin/isql[root@localhost ~]# odbcinst -junixODBC 2.3.1DRIVERS............: /etc/odbcinst.iniSYSTEM DATA SOURCES: /etc/odbc.iniFILE DATA SOURCES..: /etc/ODBCDataSourcesUSER DATA SOURCES..: /root/.odbc.iniSQLULEN Size.......: 8SQLLEN Size........: 8SQLSETPOSIROW Size.: 8
# yum install snowflake-odbc-2.25.5.x86_64.rpmInstalled:snowflake-odbc.x86_64 0:2.25.5-1Complete!Note - The installation directory is “/usr/lib64/snowflake/odbc”
Update “/etc/odbc.ini” file as below:[root@localhost etc]# cat odbc.ini[ODBC Data Sources]snowflakedb=SnowflakeDSIIDriver[snowflakedb]Driver = /usr/lib64/snowflake/odbc/lib/libSnowflake.soDescription =Server = <Full Snowflake URL>role = <Snowflake Role>database = DEMODBschema = SCHEMA1warehouse = test_whLocale=en-USPORT=443SSL=on
# isql -v snowflakedb <Snowflake account username> <account password>+---------------------------------------+| Connected! || || sql-statement || help [tablename] || quit || |+---------------------------------------+SQL> select zip, city_name,state_name from VW_ZIPCODE where zip='10001';+------+-------------------------------+-------------------------------+| ZIP | CITY_NAME | STATE_NAME |+------+-------------------------------+-------------------------------+| 10001| NEW YORK | NY |+------+-------------------------------+-------------------------------+SQLRowCount returns 11 rows fetched
$ cd $ORACLE_HOME/hs/admin$ cat initsnowflakedb.ora# This is a sample agent init file that contains the HS parameters that are# needed for the Database Gateway for ODBC## HS init parameters#HS_FDS_CONNECT_INFO = "SNOWFLAKEDB"HS_FDS_SHAREABLE_NAME = /usr/lib64/snowflake/odbc/lib/libSnowflake.soHS_LANGUAGE=AMERICAN_AMERICA.WE8MSWIN1252# HS_FDS_TRACE_LEVEL = Debug# HS_FDS_TRACE_FILE_NAME = /tmp/hstrace.log## ODBC specific environment variables#set ODBCINI=/etc/odbc.ini## Environment variables required for the non-Oracle system#
10.2. Update listener.ora in $ORACLE_HOME/network/admin as below:
[oracle@localhost admin]$ cat listener.oraLISTENER =(DESCRIPTION_LIST =(DESCRIPTION =(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))))SID_LIST_LISTENER=(SID_LIST=(SID_DESC=(SID_NAME=snowflakedb)(ORACLE_HOME=/u01/app/oracle/product/19.3.0/dbhome_1)(ENVS="LD_LIBRARY_PATH=/usr/lib64:/usr/lib64/snowflake/odbc/lib:/u01/app/oracle/product/19.3.0/dbhome_1/hs/lib:/u01/app/oracle/product/19.3.0/dbhome_1/lib")(PROGRAM=dg4odbc)))
snowflakedb=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521))(CONNECT_DATA= (SID=snowflakedb))(HS=OK))
$ lsnrctl stop
$ lsnrctl start
[oracle@localhost admin]$ tnsping snowflakedbTNS Ping Utility for Linux: Version 19.0.0.0.0 - Production on 28-SEP-2022 23:31:12Copyright (c) 1997, 2019, Oracle. All rights reserved.Used parameter files:/u01/app/oracle/product/19.3.0/dbhome_1/network/admin/sqlnet.oraUsed TNSNAMES adapter to resolve the aliasAttempting to contact (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521)) (CONNECT_DATA=(SID=snowflakedb)) (HS=OK))OK (10 msec)
SQL> CREATE PUBLIC DATABASE LINK snowflakedb connect to"<Snowflake account username>" identified by “<account password>”using 'SNOWFLAKEDB';
You can now execute the queries in SQL*Plus as below:SQL> col zip format a10SQL> col CITY_NAME format a30SQL> col STATE_NAME format a30SQL> select zip, city_name,state_name from VW_ZIPCODE@snowflakedb where zip='10001';ZIP CITY_NAME STATE_NAME---------- ------------------------------ ------------------------------10001 NEW YORK NY