Overview
Create a serverless relational database in seconds with D1. With a familiar SQL query language, point-in-time recovery, and cost-effective pricing, you are empowered to build the next big thing.
API Token Authentication
Cloudflare connections for a single database, or cloud provider are made using an API token.
To create an API token, follow these steps:
-
Log in to the Cloudflare dashboard.
-
Choose My Profile from the avatar menu icon in the top right corner.
-
Click the API Tokens tab.
-
Click the Create Token button.
-
Click Get Started next to the Create Custom Token option.
-
Enter a name for your token.
-
Permissions: The following permissions are required for D1 access:
- Account - D1 - Edit
If you wish to use the Cloudflare cloud provider, you will also need to grant the following permissions:
- Account - Account Settings - Read
-
Configure option token options as needed (e.g. IP allowlist, TTL)
-
Click the Continue to Summary button.
-
Click the Create Token button.
-
Copy the API token.
More information on API tokens can be found in the Cloudflare documentation.
Connect Single Database
To connect to a single D1 database, follow these general steps:
- Open the DBCode Extension: Launch Visual Studio Code and open the DBCode extension.
- Add a New Connection: Click on the “Add Connection” icon.
- Complete new connection form: Choose Cloudflare D1 as the type, and enter the required information.
- Connect: Click save to connect to your Cloudflare D1 database.
- Start Managing Your Databases: Once connected, you can start managing your databases directly from Visual Studio Code.
For detailed instructions on connecting to Cloudflare D1, refer to the Connect article.
Connect Multiple Databases
To connect to Cloudflare as a cloud provider and access multiple databases, follow these general steps:
- Open the DBCode Extension: Launch Visual Studio Code and open the DBCode extension.
- Add a New Connection: Click on the “Add Connection” icon.
- Select Your Provider: Choose the Cloudflare cloud provider from the list on the right.
- Authenticate: Follow the authentication process specific to the provider.
- Start Managing Your Databases: Once connected, you can start managing your databases directly from Visual Studio Code.
For detailed instructions on connecting to Cloudflare D1, refer to the Connect a Cloud Provider article.
By using Cloudflare D1 with DBCode, you can connect to your Cloudflare D1 databases, query and manage your data, and visualize your results, all directly from Visual Studio Code.
For more information about Cloudflare D1, check out Cloudflare D1.