How to Get Started with D1 Manager: Your User-Friendly Interface for Cloudflare D1

Jul 20, 2023 | Programming

D1 Manager opens the door to a smooth experience in managing your databases in Cloudflare’s serverless SQL environment. With its user-friendly web UI and robust API, you will easily handle databases, tables, and records without the hassle!

Features of D1 Manager

  • Supports multiple D1 databases for easy management.
  • List all tables within your databases effortlessly.
  • View the schema for each table to understand its structure at a glance.
  • Execute SQL queries to manipulate your data.
  • Run Semantic Queries through the OpenAI API or Cloudflare AI Worker.
  • Edit table data directly through the intuitive UI.
  • Internationalization support available in English, Chinese, Spanish, Japanese, and more.
  • Complete API support for programmatic operations (see routes/api for details).

Setting Up D1 Manager

Follow these steps to get D1 Manager up and running:

  1. Fork the D1 Manager repository from GitHub.
  2. Set up a Cloudflare Pages with your forked repository:
    • Select the SvelteKit framework preset.
    • Build command: npm run build
    • Build output directory: .svelte-kit/cloudflare
  3. Utilize Cloudflare Access to secure your site:
    • By default, it restricts access to preview pages. Ensure to add other URLs that need protection.
  4. Bind your databases to DB_* environment variables. You can bind multiple databases; for example, DB will serve as default in the UI, and DB_test for testing.

Configuring Environment Variables

To enable some plugins like the Semantic Query, certain environment variables need to be configured:

  • SHOW_INTERNAL_TABLES: Set to show internal tables (such as splite_* and d1_*) in the UI.

Using Semantic Query

D1 Manager allows you to utilize Semantic Queries via OpenAI API or Cloudflare AI Worker. Here’s how:

  • OpenAI API:
    • OPENAI_API_KEY: Your OpenAI API key for executing Semantic Queries.
    • OPENAI_API_URL: Use this to proxy requests through Cloudflare AI Gateway.
    • OPENAI_MODEL: Model for Semantic Query. Default is gpt-3.5-turbo-1106.
  • Cloudflare AI Worker:
    • AI: Bind a Cloudflare AI Worker to this variable.
    • CFAI_MODEL: Default model for Semantic Query is @cfmistral/mistral-7b-instruct-v0.1.

Troubleshooting Common Issues

If you encounter any difficulties while setting up D1 Manager, here are a few troubleshooting tips:

  • Make sure your environment variables are set properly. This includes all the necessary keys for the Semantic Query.
  • Check your Cloudflare setup and ensure that the access rules are applied to all relevant URLs.
  • If you experience errors with the API, verify your API keys and the configurations in routes/api.

For more insights, updates, or to collaborate on AI development projects, stay connected with fxis.ai.

Conclusion

At fxis.ai, we believe that such advancements are crucial for the future of AI, as they enable more comprehensive and effective solutions. Our team is continually exploring new methodologies to push the envelope in artificial intelligence, ensuring that our clients benefit from the latest technological innovations.

Visual Aid

Check out these screenshots to visualize the features better:

  • Tables Screenshot
  • Run Query Screenshot
  • Table Browser Screenshot
  • Add Record Screenshot
  • Semantic Query Screenshot

Stay Informed with the Newest F(x) Insights and Blogs

Tech News and Blog Highlights, Straight to Your Inbox