Quadratic Docs
  • Getting started
  • Examples
  • Open Quadratic
  • Quadratic AI
    • Getting started
    • Generate code
    • Generate data
    • Import PDFs
    • Import images
    • Security
  • Connections
    • SQL - getting started
    • PostgreSQL
    • MySQL
    • MS SQL Server
    • Parametrize queries
    • SQL AI assistant
    • Security
    • API requests
    • Request a connection
  • Python
    • Getting started
    • Reference cells
    • Return data to the sheet
    • Packages
    • Make an API request
    • Clean data
    • Charts/visualizations
    • Manipulate data
  • Javascript
    • Getting started
    • Reference cells
    • Return data to the sheet
    • API Requests
    • Charts/visualizations
    • Packages
  • Formulas
    • Getting started
    • AI assistant
    • Reference cells
    • Functions and operators
    • Arrays
    • Criteria
    • Wildcards
  • Spreadsheet
    • Navigating
    • Files
    • Shortcuts
    • Insert/delete rows and columns
    • Data validation
    • Present & share
    • Date-time formatting
    • Browser compatibility
  • Teams
    • Manage your team
    • Private files
    • Collaboration
    • Embedded sheets
  • Import data
    • SQL connections
    • API requests
    • Drag and drop .CSV
    • Drag and drop .Parquet
    • Import Excel files
  • Self hosting
    • Getting started
    • Docker
    • AWS
    • Azure
    • Google Cloud Platform
    • Bring your own AI
    • Other hosting
  • Quadratic for Education
    • Overview
    • Enrolling in the education plan
    • Teachers
    • Students
    • Researchers
    • Education FAQ
  • Company
    • About
    • Quadratic is source available
    • Brand assets
  • GitHub
  • Blog
  • Twitter
  • Discord
Powered by GitBook
On this page
  • Create a connection
  • Quick start
  • Create a connection
  • Step 1: press /
  • Step 2: pick the connection type
  • Step 3: follow the instructions for creating your connection
  • Use connection
  • Step 1: use your connection
  • Helpful queries
  • Read data into the spreadsheet

Was this helpful?

  1. Connections

SQL - getting started

PreviousSecurityNextPostgreSQL

Last updated 8 months ago

Was this helpful?

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 a connection

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 below.

You can also create a connection from the Dashboard > Connections under the Team menu.

Quick start

Create a connection

Step 1: press /

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.

Step 2: pick the connection type

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.

Step 3: follow the instructions for creating your connection

You can also follow this same create connection process from your team's dashboard under the connections section.

Use connection

Step 1: use your connection

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!

Helpful queries

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.

Read data into the spreadsheet

Query all data from single table into the spreadsheet

SELECT * FROM table_name

Query a limited selection (100 rows) from single table into spreadsheet

SELECT * FROM table_name 
LIMIT 100

Query specific columns from single table into the spreadsheet

SELECT column_name1, column_name2 
FROM table_name 
LIMIT 100

Query all unique values in a column

SELECT DISTINCT column_name1 
FROM table_name 
LIMIT 100

Query data conditionally

-- selects 3 specific columns from a table where column1 equals some value
SELECT column1, column2, column3
FROM table_name
WHERE column1 = 'some_value';
-- selects 3 specific columns from a table where column1 equals some value and column2 equals some value 
SELECT column1, column2, column3
FROM table_name
WHERE column1 = 'some_value' AND column2 = 5;

Extra considerations

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.

Connect your PostgreSQL database ->

Connect your MySQL database ->

Request a data connection ->

Learn about the SQL AI assistant ->

Learn about permissions and security ->

🔢
🔓
🐘
🐬
🕰️
quick start guide
Select connection type screen
Create connection screen
SQL connection type