SQL Whisperer | Start Chat
SQL Whisperer is a natural language processing chatbot that translates SQL queries into their respective commands. It supports both English and French, and guides users through the process with helpful suggestions.
def sqlTranslate(input):
# Define the language model for translation
language_model = {
'english': {
'name': 'English',
'sql_commands': ['select', 'insert', 'update', 'delete', 'alter', 'create', 'drop']
},
'french': {
'name': 'French',
'sql_commands': ['sélectionner', 'insérer', 'mettre à jour', 'supprimer', 'altérer', 'créer', 'détruire']
}
}
# Translate the input text to SQL
def sql_translate(input, language_model):
for language, translations in language_model.items():
for translation in translations['sql_commands']:
if input.startswith(translation):
return input.replace(translation, 'SELECT')
# Perform SQL translation
translated_text = sql_translate(input.lower(), language_model)
if translated_text:
return translated_text
else:
return "Sorry, I couldn't translate your input to SQL."
# Example usage:
user_input = "Select all records from the table"
translated_sql = sqlTranslate(user_input)
print("Translated SQL:", translated_sql)
Welcome to SQL Translate Chatbot!
I'm here to help you translate your natural language queries into SQL commands. It's easy! Just follow these steps:
-
Type your query using plain language.
For example:
-
To select all records from a table, you can say 'Show me all data from the table.'
-
To insert a new record, type 'Add a new entry into the table.'
-
To update a record, say 'Change data in the table.'
-
-
I support both English and French. You can switch between them at any time.
For English, keep it simple. For French, you can express your queries naturally.
-
If you ever need help or want to know which SQL commands I support, type 'help.'
I'm always here to assist you!
-
To switch to French, just type 'Passer au français.'
Let's get started! Feel free to ask any SQL-related questions or commands, and I'll do my best to assist you.