
Research Article
Prompt Template-Driven Large Model SQL Generation
@INPROCEEDINGS{10.4108/eai.18-12-2025.2365274, author={Qiurui Sun and Dong Yang}, title={Prompt Template-Driven Large Model SQL Generation}, proceedings={Proceedings of the 13th International Conference on Identification, Information and Knowledge in the Internet of Things, IIKI 2025, 18-21 December 2025, Chengdu, China}, publisher={EAI}, proceedings_a={IIKI}, year={2026}, month={6}, keywords={large model text-to-SQL metadata prompt template}, doi={10.4108/eai.18-12-2025.2365274} }- Qiurui Sun
Dong Yang
Year: 2026
Prompt Template-Driven Large Model SQL Generation
IIKI
EAI
DOI: 10.4108/eai.18-12-2025.2365274
Abstract
When executing text-to-SQL tasks, current large generative models often fail to obtain correct query results due to semantic understanding bias, which requires extensive manually written prompts for correction. This paper proposes a unified prompt template framework integrating three specialized template types (variable-type, recurrent-type, multi-branch-type) with formalized definition and algorithmic logic. By populating these templates with structured database metadata through a rule-based matching mechanism, we achieve rapid, scalable prompt generation that eliminates heavy manual intervention. Experimental results on a custom event management database demonstrate that the proposed method reduces semantic understanding bias, achieving an overall SQL generation accuracy of 87.2% (close to the 90.0% accuracy of manual prompts) while reducing prompt engineering time to 25% of the manual method. The framework’s innovation lies in its integration of programming-like logic (variable binding, loop iteration, conditional branching) into a unified prompt generation paradigm, distinguishing it from traditional string interpolation and rule-based prompt methods.


