Typically you feed the schema in as context and literally just ask the model to turn it into SQL. So a prompt of the format "Given this schema {schema}, turn this query into SQL. {query}. Return the SQL and nothing else."
Or perhaps create a lot of “known” queries as templates with good paragraph explanations and use the question to do a search for the known query. I’m new to AI so curious how it’s best utilized.
You can either have it show you the statement to confirm before executing it, or if you only want to do queries you can use a read-only database connection.