[stringtemplate-interest] SQL generation based on SQL grammer.
John Snyders
jjsnyders at rcn.com
Wed Feb 14 06:57:01 PST 2007
Yes I think StringTemplate is a good way to generate SQL statements. It
offers many benefits over having literal strings in your code.
Where a grammar is for parsing sentences in a language, StringTemplate is
for generating sentences in a language. It is a generative grammar. The
rules (grammar) of the language is built-in to your template rules.
Now quite clear what you are getting at when you say "using the SQL
grammar". Do you already have an ANTLR .g file?
In any case you will want to convert your grammar to a set of templates this
is not too difficult. The template rules often follow naturally from the
grammar.
In the grammar you would have a rule that matches a where clause and in
StringTemplate you would have a template for generating a where clause. Both
are going to rely on sub rules or templates respectively to deal with the
expressions.
As for the issue of generating random sentences over a language this sounds
like the real tricky part. Since the SQL language is infinite you wouldn't
want the random generator to get stuck in a loop generating statements that
are no longer interesting to test.
-John
-----Original Message-----
From: stringtemplate-interest-bounces at antlr.org
[mailto:stringtemplate-interest-bounces at antlr.org]On Behalf Of Ashish Malik
Sent: Wednesday, February 14, 2007 6:36 AM
To: stringtemplate-interest at antlr.org
Subject: [stringtemplate-interest] SQL generation based on SQL grammer.
Hi,
Is it possible to generate a list of SQL statements using the SQL grammar?
Say I wanted to generate random SQL queries to test a database server.
Thanks,
Ashish
DISCLAIMER ========== This e-mail may contain privileged and confidential
information which is the property of Persistent Systems Pvt. Ltd. It is
intended only for the use of the individual or entity to which it is
addressed. If you are not the intended recipient, you are not authorized to
read, retain, copy, print, distribute or use this message. If you have
received this communication in error, please notify the sender and delete
all copies of this message. Persistent Systems Pvt. Ltd. does not accept any
liability for virus infected mails.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org:8080/pipermail/stringtemplate-interest/attachments/20070214/31017c7b/attachment.html
More information about the stringtemplate-interest
mailing list