Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #49284 > unrolled thread
| Started by | Foo Stack <foostack@gmail.com> |
|---|---|
| First post | 2013-06-26 16:17 -0700 |
| Last post | 2013-06-28 11:01 +1000 |
| Articles | 3 — 3 participants |
Back to article view | Back to comp.lang.python
SQL code generation from table-free boolean queries? Foo Stack <foostack@gmail.com> - 2013-06-26 16:17 -0700
Re: SQL code generation from table-free boolean queries? Tim Chase <python.list@tim.thechases.com> - 2013-06-26 18:29 -0500
Re: SQL code generation from table-free boolean queries? alex23 <wuwei23@gmail.com> - 2013-06-28 11:01 +1000
| From | Foo Stack <foostack@gmail.com> |
|---|---|
| Date | 2013-06-26 16:17 -0700 |
| Subject | SQL code generation from table-free boolean queries? |
| Message-ID | <08a32a47-849b-4526-82c4-269df60ac818@googlegroups.com> |
Given string input such as:
foo=5 AND a=6 AND date=now OR date='2013/6' AND bar='hello'
I am going to implement:
- boolean understanding (which operator takes precendence)
- spliting off of attributes into my function which computes their table in the SQL database
- piece everything together into an SQL query
However, it came to me that this is probably a very generic thing; and there might be a library for it.
If that's so, can you recommend it?
Thanks!
[toc] | [next] | [standalone]
| From | Tim Chase <python.list@tim.thechases.com> |
|---|---|
| Date | 2013-06-26 18:29 -0500 |
| Message-ID | <mailman.3908.1372289258.3114.python-list@python.org> |
| In reply to | #49284 |
On 2013-06-26 16:17, Foo Stack wrote: > Given string input such as: > foo=5 AND a=6 AND date=now OR date='2013/6' AND bar='hello' > > I am going to implement: > > - boolean understanding (which operator takes precendence) > - spliting off of attributes into my function which computes their > table in the SQL database > - piece everything together into an SQL query > > However, it came to me that this is probably a very generic thing; > and there might be a library for it. It sounds like you might want to use pyparsing and start with something akin to this[1] -tkc [1] http://pyparsing.wikispaces.com/file/view/simpleSQL.py
[toc] | [prev] | [next] | [standalone]
| From | alex23 <wuwei23@gmail.com> |
|---|---|
| Date | 2013-06-28 11:01 +1000 |
| Message-ID | <kqimvp$i28$1@dont-email.me> |
| In reply to | #49284 |
On 27/06/2013 9:17 AM, Foo Stack wrote: > Given string input such as: > foo=5 AND a=6 AND date=now OR date='2013/6' AND bar='hello' > > I am going to implement: > > - boolean understanding (which operator takes precendence) > - spliting off of attributes into my function which computes their table in the SQL database > - piece everything together into an SQL query > > However, it came to me that this is probably a very generic thing; and there might be a library for it. Not a library per se, but I did see an article that did something quite similar using SQLAlchemy that might make a good starting point: http://www.wiggy.net/articles/sqlalchemy-in-reverse
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web