SQL - getting started
Last updated
Last updated
Use SQL to create live connections from your spreadsheets to your databases.
Once established, you have a live connection that can be rerun, refreshed, read from, and written to your SQL database.
You can both read and write to your databases from Quadratic.
Create an SQL connection by pressing /
inside a cell. From here, you can access, add, or edit connections. Here are some helpful links to get started, or follow the quick start guide below.
You can also create a connection from the Dashboard > Connections under the Team menu.
/
You can create data connections from either your spreadsheets or team's dashboard. From your sheet, press /
to open the code selection menu. You'll see both your existing connections and the prompt to manage your connections (create, edit, delete). To get started with creating a connection, choose the Manage connections option.
With the connection management screen open, you can edit an existing connection or create a new one. To create a new connection, select the connection type you want to create.
You can also follow this same create connection process from your team's dashboard under the connections section.
Once your connection has been made you can use your connection directly in the sheet. Open the code cell selection menu with /
and select your database from the list - in this example it's named Quadratic Postgres.
You can now query your database from your newly opened SQL code editor. You can view the schema or open the AI assistant in the bottom.
The results of your SQL queries are returned to the sheet, with column 0, row 0 anchored to the cell location.
You can read the data returned from queries in Python, Formulas, Javascript, etc.
Read and manipulate your data returned from SQL to summarize results, create charts, or anything else you might want to use your data for!
If you need help generating queries, we recommend first trying the AI assistant in your Quadratic code editor - its outputs are very helpful with writing everything from the simplest to most complex SQL queries.
You cannot do two queries at once in SQL in Quadratic. For example, you can not create a table and then query that table in the same SQL query.
There are some slight differences between SQL syntax across databases.
In Postgres it is best practice use quotes around table names and column names.
In MySQL it is best practice to use backticks around table names and column names.
In MS SQL Server it is best practice to use double quotes around table names and column names.
Stuck? The AI assistant in your code editor is ready and waiting to help with your queries.
Learn about the SQL AI assistant ->
Learn about permissions and security ->
Connect your PostgreSQL database ->
Connect your MySQL database ->
Request a data connection ->