[Tutor] constructing tupples in 1.5.2

Pijus Virketis virketis@fas.harvard.edu
Sat, 16 Mar 2002 01:13:00 -0500


This is a multi-part message in MIME format.

------=_NextPart_000_0013_01C1CC87.B70676F0
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Dear all,=20

I am writting a MySQL script, which will be deployed on Py1.5.2. The =
call to the database made through MySQLdb module must be in the form of =
a list of tupples (e.g. [("John", 33, "M"), ("Sally", 35, "F"), ...]. =
The thing is, I need to construct these tupples on the fly: I have a =
dictionary of values (e.g. {"name": "John", "age": 33, ... }) and I want =
to put the right values in the right places in a tupple. In Py2.2 this =
is easy, because the tupple object has a handy __add__ method, which =
concatenates two tupples. Py1.5.2, unfortunately, does not support this =
method. What would be the most effective way of doing this? A workaround =
I have though of is updating the table entry-by-entry, rather than =
making one big update call, but it's obviously less efficient to run all =
these INSERT querries.

Cheers,=20

Pijus



----------------------------
Nothing is as simple as it seems at first Or as hopeless as it seems in =
the middle Or as finished as it seems in the end. - /usr/games/fortune

------=_NextPart_000_0013_01C1CC87.B70676F0
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2713.1100" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Dear all, </FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>I am writting a MySQL script, which =
will be=20
deployed on Py1.5.2. The call to the database made through MySQLdb =
module must=20
be in the form of a list of tupples (e.g. [("John", 33, "M"), ("Sally", =
35,=20
"F"), ...]. The thing is, I need to construct these tupples on the fly: =
I have a=20
dictionary of values (e.g. {"name": "John", "age": 33, ... }) and I want =
to put=20
the right values in the right places in a tupple. In Py2.2 this is easy, =
because=20
the tupple object has a handy __add__ method, which concatenates two =
tupples.=20
Py1.5.2, unfortunately, does not support this method. What would be the =
most=20
effective way of doing this? A workaround I have though of is updating =
the table=20
entry-by-entry, rather than making one big update call, but it's =
obviously less=20
efficient to run all these INSERT querries.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Cheers, </FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Pijus</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial =
size=3D2><BR>----------------------------<BR>Nothing is as=20
simple as it seems at first Or as hopeless as it seems in the middle Or =
as=20
finished as it seems in the end. - =
/usr/games/fortune</FONT></DIV></BODY></HTML>

------=_NextPart_000_0013_01C1CC87.B70676F0--