Access sql with python, please. I'm desperate
sdd
daniels at dsl-only.net
Thu Nov 13 23:45:25 EST 2003
dd wrote:
> Thank you very much. It really helped.
You are welcome. By the way, we try to avoid "top-posting" here
in the c.l.p newsgroup, since it makes the message hard to read.
These messages get searched pretty intensively by people looking
for answers, and we like to keep them readable.
> By the way, can one do the following?
> select * from [a-query] where .......
> So, select from a query instead of a table...
Well, that depends on your database provider (Access in this case),
rather than ODBC. I have two suggestions:
1) (A Python suggestion) Just try it. Fire up Idle, pythonwin,
the python interpreter, or whatever interactive python
you find the most comfortable and type away.
2) (a database guy suggestion) Avoid it if you can. Your query
is best handled if it is in a nice, flat, and-only query. A
query optimizer "wants" to try a lot of different ways to
evaluate your query, and pick the one with the least estimated
cost based on things like indices, estimated sizes, and actual
sizes. The "nested query" form is not trivially transformed
into a form that allows for many rewrites; several cheaper
optimizers just "punt" on such queries and run the obvious way.
That said, on at least some systems you can say:
SELECT * for (SELECT age, weight FROM personnel)
WHERE age in (SELECT age FROM retirees)
-Scott David Daniels
Scott.Daniels at Acm.Org
More information about the Python-list
mailing list