In message <[EMAIL PROTECTED]>, Steve
Holden wrote:
> I suppose you are using a generator to avoid data duplication, but for
> 100,000 records this could be regarded as a premature optimisation on
> modern computers.
I was using a generator to avoid loading all those 100,000 records into
memory
Fredrik Lundh wrote:
> Frank Millman wrote:
>
> > I am reminded of a spoof Latin motto from the days of my youth -
> >
> >NIL ILLEGITIMO CARBORUNDUM
>
> isn't that usually written
>
> Illegitimi non carborundum
>
> ?
>
> or is that just due to differences between british latin and american
>>NIL ILLEGITIMO CARBORUNDUM
>
> isn't that usually written
>
> Illegitimi non carborundum
>
> or is that just due to differences between british latin and
> american latin ?
Wouldn't those differences make it
"carbourundum" vs.
"carborundum" respectively?
:*)
(however, yes, dredging
Lawrence D'Oliveiro wrote:
> In message <[EMAIL PROTECTED]>, Pom wrote:
>
>
>>I want to convert a Mysql resulset to a dictionary.
>
>
> Here's a function that does this one row at a time:
>
> def GetEachRecord(TableName, Fields, Condition, Values, Extra = "") :
> """generator which does an
On 9/26/06, Fredrik Lundh <[EMAIL PROTECTED]> wrote:
> Frank Millman wrote:
>
> > I am reminded of a spoof Latin motto from the days of my youth -
> >
> >NIL ILLEGITIMO CARBORUNDUM
>
> isn't that usually written
>
> Illegitimi non carborundum
According to the Wikipedia, neither is actually
Steve Holden wrote:
>
> Can you please stop this incessant carping? c.l.py used to be a fun
> place to hang out.
>
Hey, Steve, don't let it get to you. It's still 98% fun.
I am reminded of a spoof Latin motto from the days of my youth -
NIL ILLEGITIMO CARBORUNDUM
Translation available on r
Frank Millman wrote:
> I am reminded of a spoof Latin motto from the days of my youth -
>
>NIL ILLEGITIMO CARBORUNDUM
isn't that usually written
Illegitimi non carborundum
?
or is that just due to differences between british latin and american latin ?
--
http://mail.python.org/m
Lawrence D'Oliveiro wrote:
> In message <[EMAIL PROTECTED]>, Fredrik
> Lundh wrote:
>
>
>>Lawrence D'Oliveiro wrote:
>>
>> > SQL databases like MySQL are _designed_ for efficiency.
>>
>>unlike the Python data types, you mean ?
>
>
> Did I say it was unlike anything?
Can you please stop this in
>
> SQL databases like MySQL are _designed_ for efficiency.
Efficiency with respect to what? That statement is plain wrong. They are
designed for a pretty general case of data storage efficiency, in the
domain of relational algebra. And for a lot of use-cases, they offer a good
ratio of ease-of-u
In message <[EMAIL PROTECTED]>, Fredrik
Lundh wrote:
> Lawrence D'Oliveiro wrote:
>
> > SQL databases like MySQL are _designed_ for efficiency.
>
> unlike the Python data types, you mean ?
Did I say it was unlike anything?
--
http://mail.python.org/mailman/listinfo/python-list
Lawrence D'Oliveiro wrote:
> SQL databases like MySQL are _designed_ for efficiency.
unlike the Python data types, you mean ?
--
http://mail.python.org/mailman/listinfo/python-list
On 9/26/06, Lawrence D'Oliveiro <[EMAIL PROTECTED]> wrote:
> All right, sorry, looks like they want to load the entire table into RAM and
> key it off the first field. Kind of defeats the point of having SQL, but
> there you go...
Keeping an in-memory cache of small, unchanging, frequently-read
ta
Lawrence D'Oliveiro wrote:
> What other kind of mapping could you produce?
and here we go again. how about reading the code the OP posted, or the
first few followups?
--
http://mail.python.org/mailman/listinfo/python-list
In message <[EMAIL PROTECTED]>, Fredrik
Lundh wrote:
> Lawrence D'Oliveiro wrote:
>
> > Kind of defeats the point of having SQL, but there you go...
>
> there are plenty of reasons to use Python data structures instead of the
> SQL engine for data crunching. especially if you care about effici
Lawrence D'Oliveiro wrote:
> Kind of defeats the point of having SQL, but there you go...
there are plenty of reasons to use Python data structures instead of the
SQL engine for data crunching. especially if you care about efficiency.
--
http://mail.python.org/mailman/listinfo/python-list
In message <[EMAIL PROTECTED]>, I wrote:
> In message <[EMAIL PROTECTED]>, Fredrik
> Lundh wrote:
>
>> Lawrence D'Oliveiro wrote:
>>
>>> yield dict(zip(Fields, NextRow))
>>
>> the OP didn't ask for a field name => value mapping, though.
>
> What other kind of mapping could you produce?
Frank Millman wrote:
> Fredrik Lundh wrote:
>
>>Frank Millman wrote:
>>
>>
>>>I am reminded of a spoof Latin motto from the days of my youth -
>>>
>>> NIL ILLEGITIMO CARBORUNDUM
>>
>>isn't that usually written
>>
>>Illegitimi non carborundum
>>
>>?
>>
>>or is that just due to differences bet
In message <[EMAIL PROTECTED]>, Fredrik
Lundh wrote:
> Lawrence D'Oliveiro wrote:
>
>> yield dict(zip(Fields, NextRow))
>
> the OP didn't ask for a field name => value mapping, though.
What other kind of mapping could you produce?
--
http://mail.python.org/mailman/listinfo/python-list
Fredrik Lundh wrote:
> the OP didn't ask for a field name => value mapping, though.
footnote: but for those who want that, I strongly recommend using
something like Greg Stein's dtuple module:
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/81252
http://www.lyra.org/greg/pytho
Lawrence D'Oliveiro wrote:
> yield dict(zip(Fields, NextRow))
the OP didn't ask for a field name => value mapping, though.
--
http://mail.python.org/mailman/listinfo/python-list
Dennis Lee Bieber wrote:
> Your remap operation will create a dictionary using the first field
> as the key, and the rest of the fields as a list identified by that
> key COPY 3
the tuple-to-dictionary conversion mostly shuffles pointers around,
though; it's not a full copy of all the
In message <[EMAIL PROTECTED]>, Pom wrote:
> I want to convert a Mysql resulset to a dictionary.
Here's a function that does this one row at a time:
def GetEachRecord(TableName, Fields, Condition, Values, Extra = "") :
"""generator which does an SQL query which can return 0 or more
resul
Dennis Lee Bieber wrote:
> It might be more economical to perform the conversion while fetching
> the data:
>
> mdict = {}
> for rec in crsr:
> mdict[rec[0]] = rec[1:]
>
I didn't think of that. I just took the fetchall() from my first
version (where I looped through the tuples, whi
Tim Chase wrote:
>> def remapmysql(a):
>> return (a[0], (a[1:]))
>>
>> def test_map():
>> count = 10 # count of simulated records
>> l1 = range(0, count)
>> l2 = range(count , 2 * count )
>> l3 = range(2 * count, 3 * count )
>> z1 = zip(l1, l2, l3) # simulate a mys
Fredrik Lundh wrote:
> if you care about performance, and is using a recent Python, you could
yes i do ;-)
> try doing
>
>d1 = dict((row[0], row[1:]) for row in z1)
>
> instead, and see if that runs faster (this uses a generator expression
> instead of a callback and a full list).
>
>
>
> def remapmysql(a):
> return (a[0], (a[1:]))
>
> def test_map():
> count = 10 # count of simulated records
> l1 = range(0, count)
> l2 = range(count , 2 * count )
> l3 = range(2 * count, 3 * count )
> z1 = zip(l1, l2, l3) # simulate a mysql resultset
>
> d1
Pom wrote:
> I want to convert a Mysql resulset to a dictionary.
that is, you want to convert an array of (key, value, ...) tuples to a
dictionary containing key: (value, ...) pairs, right ?
> I made some code myself, and want to ask you if I do this the right way.
>
> def remapmysql(a):
>
Hello
I want to convert a Mysql resulset to a dictionary.
I made some code myself, and want to ask you if I do this the right way.
def remapmysql(a):
return (a[0], (a[1:]))
def test_map():
count = 10 # count of simulated records
l1 = range(0, count)
l2 = range(count , 2
28 matches
Mail list logo