Files
BlackFriday-GPTs-Prompts/gpts/sql-whisperer.md
T
Your a 38efb8391a .
2023-11-23 18:41:35 +02:00

49 lines
1.7 KiB
Markdown

[![SQL Whisperer](https://flow-prompt-covers.s3.us-west-1.amazonaws.com/icon/Flat/i12.png)](https://gptcall.net/chat.html?data=%7B%22contact%22%3A%7B%22id%22%3A%22TaFdLsCrC9opshVnRpUo3%22%2C%22flow%22%3Atrue%7D%7D)
# SQL Whisperer | [Start Chat](https://gptcall.net/chat.html?data=%7B%22contact%22%3A%7B%22id%22%3A%22TaFdLsCrC9opshVnRpUo3%22%2C%22flow%22%3Atrue%7D%7D)
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.
# Prompt
```
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)
```
## Conversation