[Python-ideas] SQL-like way to manipulate Python data structures
Steve Howell
showell30 at yahoo.com
Wed May 30 02:23:18 CEST 2007
--- Scott Dial <scott+python-ideas at scottdial.com>
wrote:
> Steve Howell wrote:
> > Presumbably most people who use SQL databases
> > already have to understand the syntax anyway. And
> > those that don't can simply ignore it.
>
> That simply will never be true. If there is new
> syntax added to Python,
> than the burden is on everyone to understand other
> people's code that
> uses such a feature. I'm very familiar with SQL and
> I am still not
> convinced that I want to see it in my Python.
I fully concede to working under the premise that most
Python programmers know SQL, and you're a perfect
example, I guess, but I realize there are exceptions,
and I don't deny that as a tradeoff, just like I don't
deny that any expansion of a language's functionality
reduces comprehension for average users. Written any
decorators lately?
> First
> of all, the concept
> of a relational table is ill-defined.
>
SQL's been around for at least 20 years, as has the
concept of a relational table. So it's not exactly
ill-defined. Start here, if you disagree:
http://en.wikipedia.org/wiki/Relational_model
> I gather from your code that you believe this to be
> a list containing
> dictionaries, but why could this not be a tuple of
> tuples?
In the code that I posted, I don't "believe" that I'm
dealing with a list of dictionaries, I "know" because
I wrote it. You can check it out yourself.
But I agree with your implied premise that the Python
interpreter doesn't know what it's dealing with, and I
fully accept in my proposal that Python, not some
third-party library, would properly throw an exception
when it found my data not to fit the relational model,
just as generator expressions sometimes throw run-time
expressions, just as lambdas throw run-time
expressions, etc. I'm ok with that.
> For that
> matter, any iterable of iterables? Or how about
> using tuple'd indices,
> and so on.. It would be impossible to graft the SQL
> language onto all of
> the variations on the idea of a "table" in Python.
>
I'm not proposing to graft SQL on to all variations of
the "table" in Python, just the ones that conform to a
relational model.
> Python does not have a relational table data
> structure, thus there
> cannot be a relational language used to address such
> a structure.
Python certainly expresses data structures that don't
fit the relational model, but please explain to me how
a list of dictionaries doesn't fit the relational
model. And don't bore me with the explanation that
dictionaries can be heterogeneous; I'd just have
Python throw an exception there.
____________________________________________________________________________________
Expecting? Get great news right away with email Auto-Check.
Try the Yahoo! Mail Beta.
http://advision.webevents.yahoo.com/mailbeta/newmail_tools.html
More information about the Python-ideas
mailing list