473,473 Members | 2,170 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

SQL Generator

Hi,

This may be a little OT, but I don't know exactly where else to post
it. I am writing a little parser that generates valid SQL using
"English like" text. I want to use this to allow non-technical users to
be able to quickly write their own queries, to search through a
database that stores information about the sales of different
companies. I can provide more information for anyone who wants to help.

Currently, the syntax is :

Select ALL PRODUCT_FILTER from COMPANY where funcname(params) conditon
.... and ITEM_DATE date_condition
Where:

product_filter specifies the product type to be included in the search
company specifies the company whose data is to be searched
funcname is an aggregate function
condition specifies the criteria for the aggregate function (i.e. a
HAVING clause)
date_condition specifies the criteria for the dates to be used in the
search

Note: there can be more than 1 aggregate function

A typical query then may look like this:

Select all 'toys' from 'Walmart' where average_sales(100) 100000 and
avaerage_cost(100,10) <= 1 and item_date between "01-Jan-00" and
"01-Jan-06"
I would like to know what the underlying SQL statement will look like,
so that I can use this knowlege to build a generic parser that creates
SQL statements from the "English like" text, using the syntax I
described above.

Jul 20 '06 #1
1 1141
On 20 Jul 2006 04:45:02 -0700, Bit Byter wrote:

(snip)
>A typical query then may look like this:

Select all 'toys' from 'Walmart' where average_sales(100) 100000 and
avaerage_cost(100,10) <= 1 and item_date between "01-Jan-00" and
"01-Jan-06"
I would like to know what the underlying SQL statement will look like,
so that I can use this knowlege to build a generic parser that creates
SQL statements from the "English like" text, using the syntax I
described above.
Hi Bit,

That depends on what the tables look like. If you post the table
structure (as CREATE TABLE statements, including all constraints,
indexes and properties), some rows of sample data (as INSERT statements)
and expected output, I'm sure that you'll get several suggestions how to
write a query.

--
Hugo Kornelis, SQL Server MVP
Jul 20 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Francis Avila | last post by:
A little annoyed one day that I couldn't use the statefulness of generators as "resumable functions", I came across Hettinger's PEP 288 (http://www.python.org/peps/pep-0288.html, still listed as...
17
by: Andrae Muys | last post by:
Found myself needing serialised access to a shared generator from multiple threads. Came up with the following def serialise(gen): lock = threading.Lock() while 1: lock.acquire() try: next...
13
by: Emmanuel | last post by:
Hi, I run across this problem, and couldn't find any solution (python 2.2.2) : Code : =========== from __future__ import generators >>> class titi:
4
by: Wai Yip Tung | last post by:
I'm attempting to turn some process than uses callback to return result into a more user friendly generator. I'm hitting some road block so any pointer would be appriciated. Let say there is an...
45
by: Joh | last post by:
hello, i'm trying to understand how i could build following consecutive sets from a root one using generator : l = would like to produce : , , , ,
12
by: Thomas Lotze | last post by:
Hi, I'm trying to figure out what is the most pythonic way to interact with a generator. The task I'm trying to accomplish is writing a PDF tokenizer, and I want to implement it as a Python...
5
by: Jerzy Karczmarczuk | last post by:
I thought that the following sequence gl=0 def gen(x): global gl gl=x yield x s=gen(1)
11
by: vbgunz | last post by:
I am afraid that this is the first time in which I would probably need something explained to me as if I were a little child. I am having a hard time getting this through my thick skull. What in...
20
by: Chris Withers | last post by:
Hi All, The following piece of code is giving me issues: from email.Charset import Charset,QP from email.MIMEText import MIMEText charset = Charset('utf-8') charset.body_encoding = QP msg =...
9
by: Kugutsumen | last post by:
I am relatively new the python language and I am afraid to be missing some clever construct or built-in way equivalent to my 'chunk' generator below. def chunk(size, items): """generate N items...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.