Get help with SQL, Python, and scripts
Specify the environment and expected output, then review and test generated code.
Updated: September 2026
Ask GPT-5.6 Luna or Gemini 3.8 Flash to draft queries, explain errors, and propose fixes. Writing code in chat does not automatically connect to your company database or execute it there.
Search the available model list and choose a model before describing the task.
Provide the context
- State the database or programming language and version.
- Provide the schema and a few synthetic rows instead of credentials or private data.
- Define output columns, filters, sorting, and exceptional cases.
- Review the code and validate it in a test environment.
SQL example
Write a MySQL 8 SELECT for production(work_date DATE, line_code VARCHAR, produced_qty INT, defect_qty INT). Return total production and defect rate by line for a parameterized date range. Calculate the ratio of sums, handle division by zero, and show sample input and expected output.
Script example
Write a Python script to combine monthly CSV files. Explain encoding, required-column validation, duplicate handling, and reporting of failed files. Save to a separate output file without overwriting inputs. Show how to run and verify it using synthetic data.
Repair an error
Paste the error and relevant code. Ask for the cause, a minimal correction, and a validation example. Check empty values, zeros, duplicates, and normal inputs before using the script for real work.
If it does not work
Provide the exact schema and version if the model invents columns or unsupported functions. Specify the language and request executable code if it returns only an explanation. Compare actual execution results with expected results instead of relying on a statement that the code succeeded.
Was this answer helpful?
