Skip to content

A Discord bot made for assisting on the concepts of Datamodelling and Databases using OpenAI and Python

License

Notifications You must be signed in to change notification settings

ShobhitRathi/SQLoad

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SQLoad

A Discord bot made for assisting on the concepts of Datamodelling and Databases using OpenAI and Python.

icon

Adding bot to your server

You can add the bot to your server using this link. NOTE: You need to have the required permissions (manage server/administrator) to be able to add the bot to your required server.

Usage

  • BOT PREFIX : ; you can use this to execute the bot commands (example - ;help)

To know the commands of the bot start by typing in ;help - This will list out all the available commands this bot has till now.

Example

If you would like to convert a natural text to its equivalent SQL query you can do so as

  1. typing ;texttosql - which will prompt for a database and then a query
  2. feed the database -
employee(person_name, street, city)
works(person_name, company_name, salary)
company(company_name, city)
manages(person_name, manager_name)
  1. enter the natural language text query to convert to SQL query - Find the names and the cities of residence of all employees who work for First Bank Corporation

  2. The bot should generate an SQL query -

SELECT person_name, city
FROM employee, works, company
WHERE employee.person_name = works.person_name AND works.company_name = company.company_name AND company.company_name = 'First Bank Corporation'

example

Commands

Currently there are these commands available to execute on the server

  1. ;help - List out the basic description of the bot and the available commands on it.
    FUNCTIONAL DEPENDENCIES TASKS
  2. ;closure - prompts for a relational Schema R and the functional Dependencies F, then returns the closure of all attributes (100% accuracy)
    SQL TASKS
  3. ;texttosql - prompts for a database and a query, then generates a SQL response query.
  4. ;sqltotext - prompts for a SQL query, then translates it into its natural language.
    DATALOG TASKS
  5. ;datalogtotext - prompts for a datalog query, then translates it into its natural language.
    TUPLE RELATIONAL CALCULUS TASKS
  6. ;trctotext - prompts for a TRC query, then translates it into its natural language.
    MISC
  7. ;creator - gives a little detail about me in case you want to contact 💁

How it works

The bot uses OpenAI API to generate the required queries from the given prompts, the bot has been coded using Python 3.9.9 which was then implemented as a discord bot.

NOTE: The answers generated the bot are done using OpenAI API GPT-3 Model engine and might not always generate correct response. However the answers generated are mostly precise and accurate to the actual answer (if they differ) and are constantly being improved. The tasks listed with (100% accuracy) are always accurate.

To communicate with discord, this bot uses the discord.py open-source library and its discord's API.

Hosting

Currently this bot is being hosted on Heroku. To host it on your own machine, make sure you download the repository and install all the dependencies on requiremments.txt. Change the enviroment variables in .env.example accordingly and rename it as .env

You can run the bot using your terminal

python3 bot.py

About

A Discord bot made for assisting on the concepts of Datamodelling and Databases using OpenAI and Python

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published