4. Load data to your table

Getting data into Space and Time.

❗

This page is part of the Getting Started guide. For the best experience, make sure to follow the guide step-by-step

There are several ways to load data into Space and Time, and you'll want to choose a method depending on the volume, velocity, and frequency of your loading. In this example, we'll show you how to load data into the DAPP_USER_WALLETS table we created in Part 3 using our REST APIs.


How to load data

Before we get started, make sure you have the API Reference page open for the Modify Resources (DML) API.

1. Craft INSERT SQL

sqlText: This will be the SQL DML command you want to run to insert data.

INSERT INTO <NEW_SCHMEA_HERE>.DAPP_USER_WALLETS (User_Wallet_Address, User_Subscription) 
VALUES ('0x2B6eD29A95753C3Ad948348e3e7b1A251080Ffb9', 'prime');

2. Set resourceId and biscuit

  • resourceId: <ENTER_SCHEMA_HERE>.<DAPP_USER_WALLETS> This will be the schema and table we created in part 3.
  • biscuit: This will be the biscuit that we generated in part 3.

2. Put it all together

curl -i --request POST \
     --url "$SxT_PROD_DML_API" \
     --header 'accept: application/json' \
     --header 'authorization: Bearer '"$AT"'' \
     --header 'biscuit: '"$BISCUIT"'' \
     --header 'content-type: application/json' \
     --data @- <<EOF
{
  "resourceId": "<NEW_SCHEMA_HERE>.DAPP_USER_WALLETS",
  "sqlText": "INSERT INTO <NEW_SCHMEA_HERE>.DAPP_USER_WALLETS (User_Wallet_Address, User_Subscription) VALUES ('0x2B6eD29A95753C3Ad948348e3e7b1A251080Ffb9', 'prime')"
}
EOF

👍

You loaded data to your table!


Bonus

  1. Let's validate the data by calling the Execute Queries (DQL) API.

Your resourceId and biscuit will be the same. Here's the sqlText you can use this to validate the data:

SELECT * FROM DAPP_USER_WALLETS

📘

Other ways to load data

For more than a few thousand rows, you can load data with streaming.

Now that you have your data in the platform, let's look at how to join it with Space and Time's indexed blockchain data using our REST APIs.