Skip to content

A JDBC driver for Cloudflare's D1 product, compatible with Jetbrains tools.

License

Notifications You must be signed in to change notification settings

isaac-mcfadyen/d1-jdbc-driver

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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:

  • 🔍 Powerful and automatic schema introspection capabilities
  • ✍️ SQL statement execution, along with auto-formatted results
  • 🔠 Support for all of the Datatype Affinities that SQLite supports (NUMERIC, TEXT, etc)

Known issues:

  • Editing data directly via the table-like interface is not supported. Editing data via SQL is still supported.
  • Foreign keys are not currently shown in the introspection window, although they are still there and working as normal.

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

About

A JDBC driver for Cloudflare's D1 product, compatible with Jetbrains tools.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages