isaac-mcfadyen / d1-jdbc-driver

A JDBC driver for Cloudflare's D1 product, compatible with Jetbrains tools.
GNU General Public License v3.0
85 stars 5 forks source link
cloudflare d1 database jdbc

D1 JDBC Driver

A JDBC driver for Cloudflare's D1 Database product!

JDBC is the technology that drives popular database tools such as Jetbrains' database functionality integrated into their editors and Datagrip, their standalone DB editor.

These tools all require a JDBC driver, an adapter that interfaces between the GUI and the Database.

The D1 JDBC Driver interfaces between these IDEs and Cloudflare's D1, and provides:

Known issues:

For more info and to get help, join us on the Cloudflare Developers Discord!

Installation instructions:

  1. Download the latest release of the D1 JDBC Driver from here.
  2. Move the .jar file to somewhere on your computer where you can store it permanently.
  3. Open Datagrip (or another Jetbrains tool) and add a new Database Driver. (Figure 1)
  4. Name it D1 JDBC Driver. Click on the plus sign beside Driver Files, select Custom JARs, then navigate to and choose the downloaded .jar file.
  5. Select org.isaacmcfadyen.D1Driver from the dropdown. (Figure 2)
  6. Go to the Options tab, scroll down to the bottom, and change the Dialect to SQLite. This is required for proper auto-complete functionality. (Figure 3)
  7. Go to the Data Sources panel, add a new Data Source, and select D1 JDBC Driver as the source. (Figure 4)
  8. Enter the URL, in the format jdbc:d1://<UUID> where <UUID> is the ID of the D1 database you were given at creation. For the User field, enter your Cloudflare Account ID, and for the Password field enter an API Token with the D1 Edit scope. (Figure 5)
  9. Hit Test Connection. If all is good, you should see a green message saying that the connection succeeded! If it failed, try going back through these steps and making sure you didn't make a typo. If you need help, join us on the Cloudflare Developers Discord. (Figure 6)

Figure 1:

Figure 1

Figure 2:

Selecting Driver Class

Figure 3:

Selecting Dialect

Figure 4:

Selecting Data Source

Figure 5:

Example of Authentication

Figure 6:

Connection Succeeded