In today's data-driven landscape, the majority of applications have evolved to become highly data intensive. However, developing successful data applications can be challenging, particularly as user numbers grow and the volume and complexity of data increase. Snowflake is the driving force behind numerous data applications, empowering software teams to enhance their engineering velocity and create scalable applications without the burden of operational complexities. With its focus on increasing engineering speed, Snowflake offers exceptional performance and scalability for applications.
To expedite the development of Data Apps, Snowflake offers the SQL API, a RESTful API that enables seamless access and manipulation of data within the Snowflake Database. The SQL API serves as a bridge between your application and Snowflake, allowing you to retrieve and update data programmatically.
In this tutorial, the application you are building helps fictitious food truck company, Tasty Bytes and Truck drivers to see the Orders placed by the customers and truck driver can complete the orders upon delivery. This tutorial will guide you through the process of utilizing the SQL API to develop a React Native application for Truck Drivers.
To run the app locally,
- Clone the repo using
git clone https://github.com/sf-gh-sjasti/TastyBytesReactNativeAppWithSnowflake-SQL_API.git reactNativeApp
- Navigate to the folder,
cd reactNativeApp
- Run
npm install
to install dependancies
- Open the
reactNativeApp
folder in VS Code or IDE of your choice. - Open the
.env
file and updatePRIVATE_KEY
value with the private key. Copy and paste the whole private key from~/.ssh/snowflake_app_key.pub
including header(-----BEGIN RSA PRIVATE KEY-----
) and footer(-----END RSA PRIVATE KEY-----
). - If you are located in us-west region, Update
SNOWFLAKE_ACCOUNT_IDENTIFIER
with your Snowflake Account (or) If you are located outside the us-west region, UpdateSNOWFLAKE_ACCOUNT_IDENTIFIER
as '.'. To get the snowflake_account value from Snowflake, runSELECT CURRENT_ACCOUNT()
in Snowsight. To get the region value from Snowflake, runSELECT CURRENT_REGION()
in Snowsight. SNOWFLAKE_ACCOUNT_IDENTIFIER and SNOWFLAKE_ACCOUNT would be same for us-west. - Update
SNOWFLAKE_ACCOUNT
with your Snowflake Account. - Update
PUBLIC_KEY_FINGERPRINT
with your user Public Key FingerPrint. To get Public Key Fingerprint, Run the following SQL in SnowsightDESCRIBE USER data_app_demo
and get RSA_PUBLIC_KEY_FP property value.
We are using Key Pair Authentication to authenticate with Snowflake using SQL API. You can refer to the Tokens.js
to understand how we are generating the JWT token. Orders.js
has the source code to render Orders screen. You can also refer to this file to find out how to initiate a SQL API call and the headers needed. OrderDetails.js
has the source code to render Order Details Screen.
- Run
npx expo start --clear
and hitw
key to run the app in a web browser - This launches the app in Web Browser
- Upon Launch, You can see the InQueue Orders Screen
- Now Click on View Order button to see the Order Details.
- Click on ORDER READY button to complete the order. This action updates the Order Status value to Completed for this Order and take you back to the InQueue Orders Screen
- Now, Click on Order History tab to see the completed orders.
For detailed steps, Refer to the Quickstart, https://quickstarts.snowflake.com/guide/developing_tasty_bytes_react_native_application_with_snowflake_sql_api