<br><br><div class="gmail_quote">2010/2/18 Rubén <span dir="ltr">&lt;<a href="mailto:parraymartinez@terra.es">parraymartinez@terra.es</a>&gt;</span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">



  
  

<div>
Perdón, me he colado... No quería decir array, no se porqué he puesto eso. Mil disculpas, no me he explicado nada bien;-)<br>
<br>
Me refería a dejar sólo <a href="mailto:correo@correo.com" target="_blank">correo@correo.com</a> y quitar &quot;{mail_uno:&quot;, &quot;}&quot;, o que sólo me salga el valor <a href="mailto:corre@correo.com" target="_blank">corre@correo.com</a> en &quot;resu&quot;<br>

<br>
Gracias de nuevo -sobre todo por la paciencia- y un saludo.<br>
<br>
<br>
<table cellspacing="0" cellpadding="0" width="100%">
<tbody><tr>
<td>
--------------------<br>
Rubén<br>
<a href="http://foroubuntu.es" target="_blank">http://foroubuntu.es</a> <br>
<br>
</td>
</tr>
</tbody></table><div class="im">
-----Mensaje original-----<br>
<b>De</b>: RadicalEd &lt;<a href="mailto:RadicalEd%20%3cwillian.radicaled@gmail.com%3e" target="_blank">willian.radicaled@gmail.com</a>&gt;<br>
</div><div class="im"><b>Reply-to</b>: La lista de python en castellano &lt;<a href="mailto:python-es@python.org" target="_blank">python-es@python.org</a>&gt;<br>
<b>Para</b>: La lista de python en castellano &lt;<a href="mailto:La%20lista%20de%20python%20en%20castellano%20%3cpython-es@python.org%3e" target="_blank">python-es@python.org</a>&gt;<br>
</div><div class="im"><b>Asunto</b>: Re: [Python-es] Buscar campo mysql<br>
</div><b>Fecha</b>: Thu, 18 Feb 2010 15:51:31 -0500<div><div></div><div class="h5"><br>
<br>
En python no existen los arrays, se llaman listas, si quieres agregar un valor a una lista primero debes crearla y luego irle asignando valores, me imágino que recorres tú tupla por un for entonces lo harías algo así:<br>

<br>
lista = []<br>
for h in range(1, 10):<br>
    lista.append(h)<br>
<br>
Solo cambia el h por tú registro de correo.<br>
<br>
<br>
2010/2/18 Rubén &lt;<a href="mailto:parraymartinez@terra.es" target="_blank">parraymartinez@terra.es</a>&gt;
<blockquote>
    Perdón, sí me imprime el resultado, pero no sólo el valor: {&#39;mail_uno&#39;: <a href="mailto:%27correo@correo.com" target="_blank">&#39;correo@correo.com</a>&#39;} Bueno, ¡voy avanzado!<br>
    <br>
    ¿Cómo hago para hacer un array con sólo la dirección de mail?
</blockquote>
<blockquote>
    <br>
    <br>
    ¡Muchas gracias!<br>
    <br>
    <table cellspacing="0" cellpadding="0" width="100%">
<tbody><tr>
<td>
--------------------<br>
Rubén<br>
<a href="http://foroubuntu.es" target="_blank">http://foroubuntu.es</a> <br>
<br>
<br>
</td>
</tr>
</tbody></table>
    -----Mensaje original-----<br>
    <br>
</blockquote>
<blockquote>
    <b>De</b>: Rubén &lt;<a href="mailto:%3d%3fISO-8859-1%3fQ%3fRub%3dE9n%3f%3d%20%3cparraymartinez@terra.es%3e" target="_blank">parraymartinez@terra.es</a>&gt;
</blockquote>
<blockquote>
    <br>
    <b>Reply-to</b>: La lista de python en castellano &lt;<a href="mailto:python-es@python.org" target="_blank">python-es@python.org</a>&gt;<br>
    <br>
</blockquote>
<blockquote>
    <b>Para</b>: RadicalEd &lt;<a href="mailto:RadicalEd%20%3cwillian.radicaled@gmail.com%3e" target="_blank">willian.radicaled@gmail.com</a>&gt;<br>
    <b>Cc</b>: La lista de python en castellano &lt;<a href="mailto:La%20lista%20de%20python%20en%20castellano%20%3cpython-es@python.org%3e" target="_blank">python-es@python.org</a>&gt;
</blockquote>
<blockquote>
    <br>
    <b>Asunto</b>: Re: [Python-es] Buscar campo mysql<br>
    <br>
</blockquote>
<blockquote>
    <b>Fecha</b>: Thu, 18 Feb 2010 20:37:32 +0100
</blockquote>
<blockquote>
    <br>
</blockquote>
<blockquote>
    <br>
    <br>
    Gracias, RadicalED<br>
    <br>
    Ahora no me da error, pero al imprimir en pantalla con resu = registro.fetchall()  print repr(resu) no me aparece el valor del campo sino (). Si cambio fetchall por fetchone me aparece None<br>
    <br>
    Sigo haciendo algo mal...<br>
    <br>
    <table cellspacing="0" cellpadding="0" width="100%">
<tbody><tr>
<td>
--------------------<br>
Rubén<br>
<a href="http://foroubuntu.es" target="_blank">http://foroubuntu.es</a> <br>
<br>
<br>
<br>
</td>
</tr>
</tbody></table>
    -----Mensaje original-----<br>
    <b>De</b>: RadicalEd &lt;<a href="mailto:RadicalEd%20%3cwillian.radicaled@gmail.com%3e" target="_blank">willian.radicaled@gmail.com</a>&gt;<br>
    <b>Para</b>: <a href="mailto:parraymartinez@terra.es" target="_blank">parraymartinez@terra.es</a> &lt;<a href="mailto:%22parraymartinez@terra.es%22%20%3cparraymartinez@terra.es%3e" target="_blank">parraymartinez@terra.es</a>&gt;, La lista de python en castellano &lt;<a href="mailto:La%20lista%20de%20python%20en%20castellano%20%3cpython-es@python.org%3e" target="_blank">python-es@python.org</a>&gt;<br>

    <b>Asunto</b>: Re: [Python-es] Buscar campo mysql<br>
    <b>Fecha</b>: Thu, 18 Feb 2010 13:58:37 -0500<br>
    <br>
    registro.execute(&quot;SELECT mail_uno FROM datos WHERE hostname = &#39;%s&#39;&quot; % nombre.value)<br>
    <br>
    2010/2/18 <a href="mailto:parraymartinez@terra.es" target="_blank">parraymartinez@terra.es</a> &lt;<a href="mailto:parraymartinez@terra.es" target="_blank">parraymartinez@terra.es</a>&gt;<br>
    <blockquote>
        <br>
        <br>
        &gt;----Mensaje original----<br>
        &gt;De: <a href="mailto:damufo@gmail.com" target="_blank">damufo@gmail.com</a><br>
        &gt;Fecha: 18/02/2010 1:12<br>
        <br>
        &gt;Para: &quot;La lista de python en castellano&quot;&lt;<a href="mailto:python-es@python.org" target="_blank">python-es@python.org</a>&gt;<br>
        <br>
        &gt;Asunto: Re: [Python-es] Buscar campo mysql<br>
        &gt;<br>
        <br>
        &gt;Será que tienes que comparar con algo el campo hostname (en el where) ?<br>
        &gt;  registro.execute(&quot;SELECT mail_uno FROM datos WHERE hostname=&#39;algo???&#39;&quot;)<br>
        <br>
        <br>
        <br>
        Me da otro error con el siguiente código:<br>
        <br>
        registro.execute(&quot;SELECT mail_uno FROM datos WHERE hostname = nombre.value&quot;) #Donde nombre.value es el hostname sacado del MS Excel<br>
        <br>
        resu = registro.fetchall()<br>
        print repr(resu)<br>
        <br>
        <br>
        Éste es el error:<br>
        <br>
        /*Traceback (most recent call last):<br>
          File &quot;exceltux&quot;, line 69, in &lt;module&gt;<br>
            registro.execute(&quot;SELECT mail_uno FROM datos WHERE hostname = nombre.value&quot;)<br>
          File &quot;/var/lib/python-support/python2.6/MySQLdb/cursors.py&quot;, line 166, in execute<br>
            self.errorhandler(self, exc, value)<br>
          File &quot;/var/lib/python-support/python2.6/MySQLdb/connections.py&quot;, line 35, in defaulterrorhandler<br>
            raise errorclass, errorvalue<br>
        _mysql_exceptions.OperationalError: (1054, &quot;Unknown column &#39;nombre.value&#39; in &#39;where clause&#39;&quot;) */<br>
        <br>
        Si  nombre.value lo entrecomillo &#39;nombre.value&#39; me imprime en pantalla &quot;None&quot;<br>
        <br>
        He buscado el error por internet pero no saco nada en claro.....<br>
        <br>
        <br>
        <br>
        <br>
        <br>
        &gt;En 2010/02/18 00:53, Rubén escribiu:<br>
        &gt; Me da el siguiente error:<br>
        &gt;<br>
        &gt; registro.execute(&quot;SELECT mail_uno FROM datos WHERE hostname&quot;)<br>
        &gt; exceltux:38: Warning: Truncated incorrect INTEGER value: HOSTNAME01<br>
        &gt;<br>
        &gt; ¿A que puede ser debido?<br>
        &gt;<br>
        &gt; Un saludo.<br>
        &gt; --------------------<br>
        &gt; Rubén<br>
        &gt; <a href="http://foroubuntu.es" target="_blank">http://foroubuntu.es</a><br>
        &gt;<br>
        &gt; -----Mensaje original-----<br>
        &gt; *De*: Rubén &lt;<a href="mailto:parraymartinez@terra.es" target="_blank">parraymartinez@terra.es</a><br>
        &gt; &lt;mailto:%<a href="mailto:3d%253fISO-8859-1%253fQ%253fRub%253dE9n%253f%253d%2520%253cparraymartinez@terra.es" target="_blank">3d%3fISO-8859-1%3fQ%3fRub%3dE9n%3f%3d%20%3cparraymartinez@terra.es</a>%3e&gt;&gt;<br>

        &gt; *Reply-to*: La lista de python en castellano &lt;<a href="mailto:python-es@python.org" target="_blank">python-es@python.org</a>&gt;<br>
        &gt; *Para*: La lista de python en castellano &lt;<a href="mailto:python-es@python.org" target="_blank">python-es@python.org</a><br>
        &gt; &lt;mailto:<a href="mailto:La%2520lista%2520de%2520python%2520en%2520castellano%2520%253cpython-es@python.org" target="_blank">La%20lista%20de%20python%20en%20castellano%20%3cpython-es@python.org</a>%3e&gt;&gt;<br>

        &gt; *Asunto*: Re: [Python-es] Buscar campo mysql<br>
        &gt; *Fecha*: Wed, 17 Feb 2010 22:53:32 +0100<br>
        &gt;<br>
        &gt; Gracias por tu respuesta.<br>
        &gt;<br>
        &gt; Entiendo entonces que por donde tengo que tirar es por el SELECT de mysql.<br>
        &gt;<br>
        &gt; Lo pruebo y os cuento.<br>
        &gt;<br>
        &gt; ¡Muchas gracias!<br>
        &gt;<br>
        &gt; --------------------<br>
        &gt; Rubén<br>
        &gt; <a href="http://foroubuntu.es" target="_blank">http://foroubuntu.es</a><br>
        &gt;<br>
        &gt;<br>
        &gt; -----Mensaje original-----<br>
        &gt; *De*: RadicalEd &lt;<a href="mailto:willian.radicaled@gmail.com" target="_blank">willian.radicaled@gmail.com</a><br>
        &gt; &lt;mailto:<a href="mailto:RadicalEd%2520%253cwillian.radicaled@gmail.com" target="_blank">RadicalEd%20%3cwillian.radicaled@gmail.com</a>%3e&gt;&gt;<br>
        &gt; *Reply-to*: La lista de python en castellano &lt;<a href="mailto:python-es@python.org" target="_blank">python-es@python.org</a>&gt;<br>
        &gt; *Para*: La lista de python en castellano &lt;<a href="mailto:python-es@python.org" target="_blank">python-es@python.org</a><br>
        &gt; &lt;mailto:<a href="mailto:La%2520lista%2520de%2520python%2520en%2520castellano%2520%253cpython-es@python.org" target="_blank">La%20lista%20de%20python%20en%20castellano%20%3cpython-es@python.org</a>%3e&gt;&gt;<br>

        &gt; *Asunto*: Re: [Python-es] Buscar campo mysql<br>
        &gt; *Fecha*: Wed, 17 Feb 2010 16:41:18 -0500<br>
        &gt;<br>
        &gt; Segun te entiendo lo que debes hacer es una consulta SQL condicional<br>
        &gt;<br>
        &gt; SELECT email FROM datos WHERE hostname=&#39;DATO EXTRAIDO DEL ARCHIVO DE EXCEL&#39;<br>
        &gt;<br>
        &gt; 2010/2/17 Rubén &lt;<a href="mailto:parraymartinez@terra.es" target="_blank">parraymartinez@terra.es</a> &lt;mailto:<a href="mailto:parraymartinez@terra.es" target="_blank">parraymartinez@terra.es</a>&gt;&gt;<br>

        &gt;<br>
        &gt;     Buenas lista,<br>
        &gt;<br>
        &gt;     Estoy liado con un programa y he llegado a un punto muerto.<br>
        &gt;<br>
        &gt;     El programa lee de un archivo de MS Excel dos columnas: una que<br>
        &gt;     viene el hostname de un equipo y otra una condición, llamémosla n.<br>
        &gt;     Por otra parte tengo una tabla en mysql con un campo para el<br>
        &gt;     hostname y otra para una dirección de mail asociada a la que se<br>
        &gt;     tiene que enviar un correo.<br>
        &gt;<br>
        &gt;     La cosa está en que llego a sacar los campos de la base de datos<br>
        &gt;     como un diccionario pero sin clave:<br>
        &gt;<br>
        &gt;     registro.execute(&quot;SELECT * FROM datos&quot;)<br>
        &gt;     resu = registro.fetchall()<br>
        &gt;     print repr(resu)<br>
        &gt;<br>
        &gt;     Lo que busco es la manera de que si en el excel se cumple la<br>
        &gt;     condición n en cierto hostname, poder sacar como char la dirección<br>
        &gt;     de mail de la base de datos asociada a ese mismo hostname.<br>
        &gt;<br>
        &gt;     Lo de la lectura del MS Excel y el envío del correo lo tengo<br>
        &gt;     solucionado.<br>
        &gt;<br>
        &gt;     ¿Alguna idea de por donde puedo tirar?<br>
        &gt;<br>
        &gt;     Gracias por vuestra ayuda y un saludo.<br>
        &gt;<br>
        &gt;     --------------------<br>
        &gt;     Rubén<br>
        &gt;     <a href="http://foroubuntu.es" target="_blank">http://foroubuntu.es</a><br>
        &gt;<br>
        &gt;<br>
        &gt;<br>
        &gt;<br>
        &gt;     _______________________________________________<br>
        &gt;     Python-es mailing list<br>
        &gt;     <a href="mailto:Python-es@python.org" target="_blank">Python-es@python.org</a> &lt;mailto:<a href="mailto:Python-es@python.org" target="_blank">Python-es@python.org</a>&gt;<br>
        &gt;     <a href="http://mail.python.org/mailman/listinfo/python-es" target="_blank">http://mail.python.org/mailman/listinfo/python-es</a><br>
        &gt;     FAQ: <a href="http://python-es-faq.wikidot.com/" target="_blank">http://python-es-faq.wikidot.com/</a><br>
        &gt;<br>
        &gt;<br>
        &gt;<br>
        &gt;<br>
        &gt; --<br>
        &gt; The past are just memories, the future are just dreams!!!<br>
        &gt; <a href="http://foros.solocodigo.com" target="_blank">http://foros.solocodigo.com</a><br>
        &gt; <a href="http://radicalpython.blogspot.com" target="_blank">http://radicalpython.blogspot.com</a><br>
        &gt; <a href="http://revistacodigolatino.blogspot.com" target="_blank">http://revistacodigolatino.blogspot.com</a><br>
        &gt;<br>
        &gt; _______________________________________________<br>
        &gt; Python-es mailing list<br>
        &gt; <a href="mailto:Python-es@python.org" target="_blank">Python-es@python.org</a>  &lt;mailto:<a href="mailto:Python-es@python.org" target="_blank">Python-es@python.org</a>&gt;<br>
        &gt; <a href="http://mail.python.org/mailman/listinfo/python-es" target="_blank">http://mail.python.org/mailman/listinfo/python-es</a><br>
        &gt; FAQ:<a href="http://python-es-faq.wikidot.com/" target="_blank">http://python-es-faq.wikidot.com/</a><br>
        &gt; _______________________________________________<br>
        &gt; Python-es mailing list<br>
        &gt; <a href="mailto:Python-es@python.org" target="_blank">Python-es@python.org</a>  &lt;mailto:<a href="mailto:Python-es@python.org" target="_blank">Python-es@python.org</a>&gt;<br>
        &gt; <a href="http://mail.python.org/mailman/listinfo/python-es" target="_blank">http://mail.python.org/mailman/listinfo/python-es</a><br>
        &gt; FAQ:<a href="http://python-es-faq.wikidot.com/" target="_blank">http://python-es-faq.wikidot.com/</a><br>
        &gt;<br>
        &gt;<br>
        &gt;<br>
        &gt; _______________________________________________<br>
        &gt; Python-es mailing list<br>
        &gt; <a href="mailto:Python-es@python.org" target="_blank">Python-es@python.org</a><br>
        &gt; <a href="http://mail.python.org/mailman/listinfo/python-es" target="_blank">http://mail.python.org/mailman/listinfo/python-es</a><br>
        &gt; FAQ: <a href="http://python-es-faq.wikidot.com/" target="_blank">http://python-es-faq.wikidot.com/</a><br>
        _______________________________________________<br>
        Python-es mailing list<br>
        <a href="mailto:Python-es@python.org" target="_blank">Python-es@python.org</a><br>
        <a href="http://mail.python.org/mailman/listinfo/python-es" target="_blank">http://mail.python.org/mailman/listinfo/python-es</a><br>
        FAQ: <a href="http://python-es-faq.wikidot.com/" target="_blank">http://python-es-faq.wikidot.com/</a><br>
        <br>
        <br>
        <br>
        <br>
        _______________________________________________<br>
        Python-es mailing list<br>
        <a href="mailto:Python-es@python.org" target="_blank">Python-es@python.org</a><br>
        <a href="http://mail.python.org/mailman/listinfo/python-es" target="_blank">http://mail.python.org/mailman/listinfo/python-es</a><br>
        FAQ: <a href="http://python-es-faq.wikidot.com/" target="_blank">http://python-es-faq.wikidot.com/</a><br>
        <br>
    </blockquote>
    <br>
    <br>
    <br>
    -- <br>
    The past are just memories, the future are just dreams!!!<br>
    <a href="http://foros.solocodigo.com" target="_blank">http://foros.solocodigo.com</a><br>
    <a href="http://radicalpython.blogspot.com" target="_blank">http://radicalpython.blogspot.com</a><br>
    <a href="http://revistacodigolatino.blogspot.com" target="_blank">http://revistacodigolatino.blogspot.com</a> 
<pre>_______________________________________________
Python-es mailing list
<a href="mailto:Python-es@python.org" target="_blank">Python-es@python.org</a>
<a href="http://mail.python.org/mailman/listinfo/python-es" target="_blank">http://mail.python.org/mailman/listinfo/python-es</a>
FAQ: <a href="http://python-es-faq.wikidot.com/" target="_blank">http://python-es-faq.wikidot.com/</a>
</pre>
</blockquote>
<blockquote>
    <br>
    _______________________________________________<br>
    Python-es mailing list<br>
    <a href="mailto:Python-es@python.org" target="_blank">Python-es@python.org</a><br>
    <a href="http://mail.python.org/mailman/listinfo/python-es" target="_blank">http://mail.python.org/mailman/listinfo/python-es</a><br>
    FAQ: <a href="http://python-es-faq.wikidot.com/" target="_blank">http://python-es-faq.wikidot.com/</a><br>
    <br>
</blockquote>
<br>
<br>
<br>
-- <br>
The past are just memories, the future are just dreams!!!<br>
<a href="http://foros.solocodigo.com" target="_blank">http://foros.solocodigo.com</a><br>
<a href="http://radicalpython.blogspot.com" target="_blank">http://radicalpython.blogspot.com</a><br>
<a href="http://revistacodigolatino.blogspot.com" target="_blank">http://revistacodigolatino.blogspot.com</a>
<pre>_______________________________________________
Python-es mailing list
<a href="mailto:Python-es@python.org" target="_blank">Python-es@python.org</a>
<a href="http://mail.python.org/mailman/listinfo/python-es" target="_blank">http://mail.python.org/mailman/listinfo/python-es</a>
FAQ: <a href="http://python-es-faq.wikidot.com/" target="_blank">http://python-es-faq.wikidot.com/</a>
</pre>
</div></div></div>

<br>_______________________________________________<br>
Python-es mailing list<br>
<a href="mailto:Python-es@python.org">Python-es@python.org</a><br>
<a href="http://mail.python.org/mailman/listinfo/python-es" target="_blank">http://mail.python.org/mailman/listinfo/python-es</a><br>
FAQ: <a href="http://python-es-faq.wikidot.com/" target="_blank">http://python-es-faq.wikidot.com/</a><br>
<br></blockquote></div><br><div><br></div><div>Lo que tienes entre manos es un diccionario, por lo que para acceder al valor lo haces por la clave:</div><div><br></div><div><div>&gt;&gt;&gt; {&#39;mail_uno&#39;: &#39;<a href="mailto:correo@correo.com">correo@correo.com</a>&#39;}[&#39;mail_uno&#39;]</div>
<div>&#39;<a href="mailto:correo@correo.com">correo@correo.com</a>&#39;</div><div><br></div><div><br></div><div>Un poco de lectura no viene mal:</div><div><a href="http://docs.python.org/tutorial/datastructures.html#dictionaries">http://docs.python.org/tutorial/datastructures.html#dictionaries</a></div>
<div><a href="http://es.wikipedia.org/wiki/SQL">http://es.wikipedia.org/wiki/SQL</a></div><div><br></div><div>Un saludo,</div></div><div><br></div>