Here's a sample script (cut between the lines):<div><br></div><div>-------------------------------------------------------------------</div><div><div>#!/usr/bin/env python</div><div><br></div><div>import cx_Oracle</div>
<div><br></div><div># Establish a connection:</div><div>connection = cx_Oracle.connect('user/password@database')</div><div><br></div><div># Create a cursor object:</div><div>cursor = connection.cursor()</div><div>
<br></div><div># Run your query:</div><div>cursor.execute('''select to_char(sysdate, 'yyyy-mm-dd hh24:mi:ss') now from dual''')</div><div><br></div><div># Get the column names:</div><div>cols = tuple([x[0].lower() for x in cursor.description])</div>
<div><br></div><div># Fetch the results:</div><div>rs = cursor.fetchall()</div><div><br></div><div># Turn them into rows:</div><div>rows = [dict(zip(cols, r)) for r in rs]</div><div><br></div><div># Loop through the rows and print out the results:</div>
<div>for row in rows:</div><div> print 'According to Oracle, the time now is:', row['now']</div><div><br></div><div># That's it!</div><div><div>-------------------------------------------------------------------</div>
<div></div></div><div><br></div><div>Replace user/password@database with the string you would use to connect to Oracle with SQL*Plus, and that should do it.</div><div><br></div><div>Good luck!</div><div><br></div><div>Regards,</div>
<div><br></div><div>.... Bob</div><div><br></div><div class="gmail_quote">2008/6/11 Marcel Rosa <<a href="mailto:marcelr_br@yahoo.com.br">marcelr_br@yahoo.com.br</a>>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<table cellspacing="0" cellpadding="0" border="0" style="font-family:arial;font-size:10pt;color:#000000;background-color:#ffffff;width:100%"><tbody><tr><td valign="top" style="font:inherit"><p>I am Oracle DBA and would like to use a python to developer some intranet report, </p>
<p>do you have same examples?</p>
<p> </p>
<p>thanks.</p></td></tr></tbody></table><br><div class="WgoR0d">
<hr size="1">Abra sua conta no <a href="http://br.rd.yahoo.com/mail/taglines/mail/*http://br.mail.yahoo.com/" target="_blank">Yahoo! Mail</a>, o único sem limite de espaço para armazenamento!
</div><br>_______________________________________________<br>
DB-SIG maillist - <a href="mailto:DB-SIG@python.org">DB-SIG@python.org</a><br>
<a href="http://mail.python.org/mailman/listinfo/db-sig" target="_blank">http://mail.python.org/mailman/listinfo/db-sig</a><br>
<br></blockquote></div><br></div>