logo

docs

about

contact

Introduction

This guide will help you get started and make your first query to your global SQLite database. It also assumes you have a basic understanding of SQL and how to interact with a database.

You can get started in 3 simple steps:

  1. Create a database from the dashboard.
  2. Retrieve your database token from the dashboard and securely store it.
  3. Make your first query to https://db.dzero.dev:

Concepts

  • SQLite: A lightweight database engine that is fast, small, portable and highly reliable with a fully featured SQL implementation.
  • Edge Locations: Are hundreds of different servers spread across the globe where you SQL database is instantly replicated to, allowing low latency and high speed times regardless of your user location.
  • Transactions: A transaction is a SQL operations that allow data reliability and consistency in situations where there data conflicts, this is important especially with Edge databases which guarantees immediate data consistency across the Edge.
  • Token: A key that allows full access to your database, keep this secure. Each database has a unique token.

These concepts are good to understand but not something you have to worry about when using Dzero, as all replications are automatically managed with zero configurations.

Prerequisites

  1. Got early access and signed up for a Dzero account. If not, sign up here.
  2. Create a database from the dashboard.
  3. Retrieve your database token from the dashboard and securely store it

The API

All interactions with your database goes through a secured & fastāš” HTTPS REST API, which makes it simple to integrate with any programming language, framework and platform.

API Authentication

You need to pass in your database token in the token header field to authenticate your requests. Each database has a unique token which you can retrieve from the dashboard.

Making your first query


JS Client

JS Fetch

Curl

PHP

Python

Java

Install JS/TS client

We have a small Javascript/Typescript client written with fetch which is supported in every JS environment/framework. No npm install required, just copy and paste to your code base. Feel free to write similar clients around your favorite language, reach out and we'll publish it here.

Create a table

Run the following query in the sql field and you would have created your first table.

Response

All query responses are in JSON format consisting of root keys, meta and results. The meta key contains metadata about the query execution such as the rows read & written which can be used to estimate performance and cost. The results key contains the actual query results if any.

Inserting data

View all tables

Querying data

Prepared statements

Prepared statements allow you to reuse the same query with different parameters, this is useful for improvement in performance. Using the params field in the request body, you can pass in the parameters that will bind to your quires in oder of the array.


JS Client

JS Fetch

Curl

PHP

Python

Java

Query methods

By default all queries run in the all method, you can change this to exec by passing in the method field in the request body.

"all" method


JS Client

JS Fetch

Curl

PHP

Python

Java

Returns all rows as an array of objects

"exec" method

This allows you to run larger and multiple queries as once which is great for performing migrations or large tasks. It's not recommended to use as it has poorer performance and less safe. Parameters bindings are not supported in this method.


JS Client

JS Fetch

Curl

PHP

Python

Java

Batching

Batching allows you to send multiple query statements as a single call and each statement will be executed sequentially, if any statement fails within the sequence, the entire batch will be rolled back.

You can batch simply by passing an array of SQL statements to the sql param.


JS Client

JS Fetch

Curl

PHP

Python

Java