Giter VIP home page Giter VIP logo

sqlchat's Introduction

SQL Chat banner

SQL Chat

vercel

English | 中文 | Español

What

SQL Chat is a chat-based SQL client, which uses natural language to communicate with the database to implement operations such as query, modification, addition, and deletion of the database.

Screenshot

Screenshot

Screenshot

Why

As we enter the Developer Tools 2.0 era, there is a massive opportunity to rebuild the existing tools using the chat-based interface. SQL Client is no exception. Instead of navigating across many UI controls, a chat-based interface is much more intuitive. Of course, only if that works, and our goal is to deliver that experience.

How

SQL Chat is built by Next.js, it supports the following databases and will add more over time:

  • MySQL
  • PostgreSQL
  • MSSQL
  • TiDB Cloud

IP Whitelisting

If you use sqlchat.ai to connect to your database, you need to add 0.0.0.0 (allow all connections) to the database whitelist IP. Because sqlchat.AI is hosted on Vercel which uses dynamic IP. If this is a concern, please consider the self-host option below.

Data Privacy

See SQL Chat Privacy Policy.

Self-host

Docker

If you just want to run for your own use, supply the following options:

  • NEXTAUTH_SECRET
  • OPENAI_API_KEY
docker run --name sqlchat --platform linux/amd64 --env NEXTAUTH_SECRET="$(openssl rand -hex 5)" --env OPENAI_API_KEY=<<YOUR OPENAI KEY>> -p 3000:3000 --hostname localhost sqlchat/sqlchat
  • Pass an arbitrary string to NEXTAUTH_SECRET otherwise next-auth will complain.
  • If you chat to the database on the same host, you need to use host.docker.internal as the host in the database connection setting.

Startup options

TL;DR

  • If you just want to use for yourself, then run without database. Check .env.nodb.
  • If you want to offer a similar service as sqlchat.ai, then run with database, check .env.usedb. The database is used to store account, usage info.

OpenAI related

  • OPENAI_API_KEY: OpenAI API key. You can get one from here.

  • OPENAI_API_ENDPOINT: OpenAI API endpoint. Defaults to https://api.openai.com.

  • NEXT_PUBLIC_ALLOW_SELF_OPENAI_KEY: Set to true to allow users to bring their own OpenAI API key.

Database related

  • NEXT_PUBLIC_USE_DATABASE: Set to true to start SQL Chat with database. This will enable following features:
    1. Account system.
    2. Per-user quota enforcement.
    3. Payment.
    4. Usage data collection.
  • DATABASE_URL: Applicable if NEXT_PUBLIC_USE_DATABASE is true. Postgres connection string to store data. e.g. postgresql://postgres:YOUR_PASSWORD@localhost:5432/sqlchat?schema=sqlchat.

Local Development

  1. Install dependencies

    pnpm i
  2. Generate prisma client

    pnpm prisma generate
  3. Make a copy of the example environment variables file:

    cp .env.usedb .env
  4. Add your API key and OpenAI API Endpoint(optional) to the newly created .env file.

Setup database

You can skip this section with NEXT_PUBLIC_USE_DATABASE=false if you don't build features requiring database

  1. Start a Postgres instance. For mac, you can use StackbBricks, DBngin or Postgres.app.

  2. Create a database:

    CREATE DATABASE sqlchat;

    In .env file, assign the connection string to environment variable DATABASE_URL and DATABASE_DIRECT_URL. This article explains why we need two URLs.

  3. Set up database schema

    pnpm prisma migrate dev
  4. (Optional) Seed data

    pnpm prisma db seed

Star History

Star History Chart

Community

Hang out on Discord

Follow us on Twitter

sqlchat

Sponsors

License

This project is under the BSL License. See the LICENSE file for the full license text.

Common Error Message

Please sign up to get free quota

See this issue.

You exceeded your current quota, please check your plan and billing details

openai quota

Your OpenAI Key has run out of quota. Please check your OpenAI account.

Failed to request message, please check your network

network error

Please make sure you have a stable network connection which can access the OpenAI API endpoint.

ping api.openai.com

If you cannot access the OpenAI API endpoint, you can try to set the OPENAI_API_ENDPOINT in UI or environment variable.

sqlchat's People

Contributors

akrista avatar alitrack avatar boojack avatar correctroadh avatar emostar avatar evanlong0803 avatar icemap avatar jaberwiki avatar lushenle avatar techdjinn avatar tianzhou avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.