Code suggestion - List comprehension
Ben Finney
ben+python at benfinney.id.au
Thu Dec 12 17:35:45 EST 2013
Shyam Parimal Katti <spk265 at nyu.edu> writes:
> A semi-colon in the string value indicates the termination of a sql query.
> So the expected out come is a conversion to a list of valid sql queries:
> ['drop table sample_table;', 'create table sample_test (col1 int);',
> 'select col1 from sample_test;']
I presume these strings are split from lines of input. If so, you would
be better advised to use an SQL parsing library in the first place
<URL:https://pypi.python.org/pypi/sqlparse/>, to get distinct SQL
statements from a text stream.
--
\ “We must find our way to a time when faith, without evidence, |
`\ disgraces anyone who would claim it.” —Sam Harris, _The End of |
_o__) Faith_, 2004 |
Ben Finney
More information about the Python-list
mailing list