Build a web application and let ChatGPT help me write SQL

Hello everyone, my name is Ling Lan.

To get straight to the point, I built a web application called sql-translate. The access link is hanging in the navigation bar of my personal blog (https://linglan01.cn/about), you can also visit https://www.linglan01.cn/c/sql-translate/Direct access to sql-translate.

Its main functions are: human language to SQL, SQL to human language. This article demonstrates how to convert human language into SQL.
show time!!!

Human language to SQL

Case number one

Input:
creates a table named "T_USERS", which contains the following fields:

  1. id: an integer type field used as the primary key.
  2. username: A string type field with a maximum length of 50, used to store usernames.
  3. email: A string type field with a maximum length of 100, used to store email addresses.
  4. age: Integer type field, used to store age.
  5. gender: A string type field with a maximum length of 10, used to store gender information.

ChatGPT output:create TABLE T_USERS (id integer primary key, username varchar(50),email varchar(100),age integer gender varchar(10));

The effect is like this:

Case 2

I set Table Schema:

1CREATE TABLE T_USERS (
  id INT PRIMARY KEY,
  username VARCHAR(50),
  email VARCHAR(100),
  age INT,
  gender VARCHAR(10)
);

Input: Expand the table named T_USERS to add fields for school, academic qualifications, and working company
ChatGPT output:alteb table t_users add column school varchar(100), add column education varchar(100) add column company varchar(100);

The effect is like this:

Case three

Input: Query all data whose username is programmer Ling Lan and email is [email protected]

ChatGPT output:select * from t_users where username = '程序员凌览' and email = '[email protected]';

The effect is like this:

at last

Whether you are a beginner or an experienced SQL user, you can play it. I strongly recommend you try sql-translate, write less curd, wouldn't it be nice to get off work early?

Guess you like

Origin blog.csdn.net/qq_45472813/article/details/134544853