Access any SQL database from a HTTP request

A simple Sequelize wrapper to access any SQL database over HTTP

Http2SQL is a free api which will allow you to query any SQL database from an HTTP request. It uses Sequelize to handle the connection

It's free to use and doesn't require an API key or authentication. The code is available on Github

With Zero you can build great interactive dashboards pulling data directly from your SQL database! It's free! Give it a try at https://zero.sh/play

1. Make sure that your request is private and from a secure connection

This API requires that you pass the entire database connection URI. This contains your username and password so never use this API directly from your frontend or from somewhere where users can access it.

If you use it on Zero.sh save your connection string on a secret and use that.

2. Format your request

This API accepts only POST requests to this endpoint: https://labs.zero.sh/api/http2sql

The following data is allowed:

  • uri: You database connection uri, e.g. postgres:// ....
  • query: Your SQL query, e.g. Select * from "Users"
  • config_object: If you don't want to pass the URI you can alternatively pass a Sequelize connection object - e.g. {dialect: 'mysql', etc}

You always need to pass a query and either the uri or the config_object

3. Your response

The tool will either return and error or, in case of success the sequelize response. (Note: This can be null, for example INSERT INTO statements)

4. An example:

This is how you would create a table of users on Zero:

// On a Table Block

const post_data = {
  uri:secrets.db_uri, // db_uri is something like: postgres://user:password@db:port/user 
  query: `Select * from "Users"`
}
const {data} = await api.post("https://labs.zero.sh/api/http2sql", post_data)

return data

Questions?

Feel free to send us an email at support@zero.sh or open an issue on Github

Last Updated: July 13, 2021

Need Help?

Have a look at the docs or the examples above

Questions?

Chat with us or leave a message below