<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Gustavo Henrique.net &#187; python</title>
	<atom:link href="http://www.gustavohenrique.net/brogui/category/python/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.gustavohenrique.net/brogui</link>
	<description>Só mais um blog com Wordpress</description>
	<lastBuildDate>Tue, 29 Jun 2010 00:00:51 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Django usando Pisa para converter HTML para PDF</title>
		<link>http://www.gustavohenrique.net/brogui/2010/02/django-usando-pisa-para-converter-html-para-pdf/</link>
		<comments>http://www.gustavohenrique.net/brogui/2010/02/django-usando-pisa-para-converter-html-para-pdf/#comments</comments>
		<pubDate>Wed, 03 Feb 2010 18:02:49 +0000</pubDate>
		<dc:creator>gustavohenrique</dc:creator>
				<category><![CDATA[Django]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[pdf]]></category>
		<category><![CDATA[pisa]]></category>

		<guid isPermaLink="false">http://www.gustavohenrique.net/brogui/?p=235</guid>
		<description><![CDATA[
Pisa é um conversor de HTML/XHTML/CSS para PDF, escrito em Python e baseado nas bibliotecas Reportlab, PyPDF, TechGame Networks CSS e HTML5lib. Seu foco principal não é gerar páginas perfeitas para impressão, mas utilizar HTML e CSS para gerar PDFs dentro de aplicações.
A instalação pode ser feita através do código no site do projeto ou [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.gustavohenrique.net/brogui/wp-content/uploads/2010/02/tower_pisa.jpg"><img src="http://www.gustavohenrique.net/brogui/wp-content/uploads/2010/02/tower_pisa.jpg" alt="Torre de Pisa" title="Torre de Pisa" width="130" height="200" class="aligncenter size-full wp-image-236" /></a></p>
<p>Pisa é um conversor de HTML/XHTML/CSS para PDF, escrito em Python e baseado nas bibliotecas Reportlab, PyPDF, TechGame Networks CSS e HTML5lib. Seu foco principal não é gerar páginas perfeitas para impressão, mas utilizar HTML e CSS para gerar PDFs dentro de aplicações.<br />
A instalação pode ser feita através do código no <a href="http://pypi.python.org/pypi/pisa/" target="_blank">site do projeto</a> ou pelo comando <code>easy_install pisa</code>.</p>
<p>Crie um arquivo chamado <code>report.py</code> dentro do diretório do projeto contendo o código abaixo:</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #808080; font-style: italic;"># -*- coding: utf-8 -*-</span>
<span style="color: #ff7700;font-weight:bold;">from</span> django <span style="color: #ff7700;font-weight:bold;">import</span> http
<span style="color: #ff7700;font-weight:bold;">from</span> django.<span style="color: black;">template</span>.<span style="color: black;">loader</span> <span style="color: #ff7700;font-weight:bold;">import</span> get_template
<span style="color: #ff7700;font-weight:bold;">from</span> django.<span style="color: black;">template</span> <span style="color: #ff7700;font-weight:bold;">import</span> Context
<span style="color: #ff7700;font-weight:bold;">import</span> ho.<span style="color: black;">pisa</span> <span style="color: #ff7700;font-weight:bold;">as</span> pisa
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">cStringIO</span> <span style="color: #ff7700;font-weight:bold;">as</span> <span style="color: #dc143c;">StringIO</span>
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">cgi</span>, <span style="color: #dc143c;">os</span>
&nbsp;
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> fetch_resources<span style="color: black;">&#40;</span>uri, rel<span style="color: black;">&#41;</span>:
    path = <span style="color: #483d8b;">'/path/para/diretorio/contendo/imagens/a/serem/exibidas'</span>
    <span style="color: #ff7700;font-weight:bold;">return</span> path
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> write_to_pdf<span style="color: black;">&#40;</span>template_src, context_dict, filename<span style="color: black;">&#41;</span>:
    template = get_template<span style="color: black;">&#40;</span>template_src<span style="color: black;">&#41;</span>
    context = Context<span style="color: black;">&#40;</span>context_dict<span style="color: black;">&#41;</span>
    html  = template.<span style="color: black;">render</span><span style="color: black;">&#40;</span>context<span style="color: black;">&#41;</span>
    result = <span style="color: #dc143c;">StringIO</span>.<span style="color: #dc143c;">StringIO</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
    pdf = pisa.<span style="color: black;">pisaDocument</span><span style="color: black;">&#40;</span><span style="color: #dc143c;">StringIO</span>.<span style="color: #dc143c;">StringIO</span><span style="color: black;">&#40;</span>html.<span style="color: black;">encode</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;UTF-8&quot;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>, result, link_callback=fetch_resources<span style="color: black;">&#41;</span>
    <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #ff7700;font-weight:bold;">not</span> pdf.<span style="color: black;">err</span>:
        response = http.<span style="color: black;">HttpResponse</span><span style="color: black;">&#40;</span>mimetype=<span style="color: #483d8b;">'application/pdf'</span><span style="color: black;">&#41;</span>
        response<span style="color: black;">&#91;</span><span style="color: #483d8b;">'Content-Disposition'</span><span style="color: black;">&#93;</span> = <span style="color: #483d8b;">'attachment; filename=%s.pdf'</span> <span style="color: #66cc66;">%</span> filename
        response.<span style="color: black;">write</span><span style="color: black;">&#40;</span>result.<span style="color: black;">getvalue</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
        <span style="color: #ff7700;font-weight:bold;">return</span> response
    <span style="color: #ff7700;font-weight:bold;">return</span> http.<span style="color: black;">HttpResponse</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'Problema ao gerar PDF: %s'</span> <span style="color: #66cc66;">%</span> <span style="color: #dc143c;">cgi</span>.<span style="color: black;">escape</span><span style="color: black;">&#40;</span>html<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span></pre></div></div>

<p>E agora, dentro de uma <code>view</code>, é preciso importar o arquivo <code>report.py</code> e chamar a função <code>write_to_pdf</code> para fazer a conversão:</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #808080; font-style: italic;"># views.py</span>
<span style="color: #ff7700;font-weight:bold;">from</span> report <span style="color: #ff7700;font-weight:bold;">import</span> write_to_pdf
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> listar_clientes_cadastrados<span style="color: black;">&#40;</span>request<span style="color: black;">&#41;</span>:
    clientes = Cliente.<span style="color: black;">objects</span>.<span style="color: #008000;">all</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
    <span style="color: #ff7700;font-weight:bold;">return</span> write_to_pdf<span style="color: black;">&#40;</span><span style="color: #483d8b;">'relatorio.html'</span>, <span style="color: black;">&#123;</span><span style="color: #483d8b;">'clientes'</span>: clientes<span style="color: black;">&#125;</span>, <span style="color: #483d8b;">'nome_do_arquivo_pdf'</span><span style="color: black;">&#41;</span></pre></div></div>

<p>A função <code>write_to_pdf</code> recebe como parâmetro o nome do arquivo HTML que será convertido, as variáveis que serão tratadas dentro desse arquivo e o nome que o arquivo PDF sem a extensão. Retorna o download do arquivo PDF.</p>
<p>Conforme citado no início do post, a conversão não é perfeita. Por exemplo, às vezes uma tabela apresenta mínimas deformações, não fica igual como na versão HTML. Apesar disso Pisa é uma ótima solução que muitas vezes ajuda bastante e, como puderam ver, é muito fácil de usar.</p>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a><strong><em>Compartilhe esse artigo</em></strong></a>
<br />
<div class="d">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://buzz.yahoo.com/submit?submitUrl=http%3A%2F%2Fwww.gustavohenrique.net%2Fbrogui%2F2010%2F02%2Fdjango-usando-pisa-para-converter-html-para-pdf%2F&amp;submitHeadline=Django+usando+Pisa+para+converter+HTML+para+PDF&amp;submitSummary=" rel="nofollow" title="Adicionar ao&nbsp;Buzz"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/buzz.png" title="Adicionar ao&nbsp;Buzz" alt="Adicionar ao&nbsp;Buzz" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http%3A%2F%2Fwww.gustavohenrique.net%2Fbrogui%2F2010%2F02%2Fdjango-usando-pisa-para-converter-html-para-pdf%2F&amp;title=Django+usando+Pisa+para+converter+HTML+para+PDF" rel="nofollow" title="Adicionar ao&nbsp;Del.icio.us"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/delicious.png" title="Adicionar ao&nbsp;Del.icio.us" alt="Adicionar ao&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.gustavohenrique.net%2Fbrogui%2F2010%2F02%2Fdjango-usando-pisa-para-converter-html-para-pdf%2F&amp;title=Django+usando+Pisa+para+converter+HTML+para+PDF" rel="nofollow" title="Adicionar ao&nbsp;digg"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/digg.png" title="Adicionar ao&nbsp;digg" alt="Adicionar ao&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/sharer.php?u=http%3A%2F%2Fwww.gustavohenrique.net%2Fbrogui%2F2010%2F02%2Fdjango-usando-pisa-para-converter-html-para-pdf%2F" rel="nofollow" title="Adicionar ao&nbsp;Facebook"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/facebook.png" title="Adicionar ao&nbsp;Facebook" alt="Adicionar ao&nbsp;Facebook" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http%3A%2F%2Fwww.gustavohenrique.net%2Fbrogui%2F2010%2F02%2Fdjango-usando-pisa-para-converter-html-para-pdf%2F&amp;title=Django+usando+Pisa+para+converter+HTML+para+PDF" rel="nofollow" title="Adicionar ao&nbsp;Google Bookmarks"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/google.png" title="Adicionar ao&nbsp;Google Bookmarks" alt="Adicionar ao&nbsp;Google Bookmarks" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.mister-wong.com/index.php?action=addurl&amp;bm_url=http%3A%2F%2Fwww.gustavohenrique.net%2Fbrogui%2F2010%2F02%2Fdjango-usando-pisa-para-converter-html-para-pdf%2F&amp;bm_description=Django+usando+Pisa+para+converter+HTML+para+PDF" rel="nofollow" title="Adicionar ao&nbsp;Mister Wong"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/misterwong.png" title="Adicionar ao&nbsp;Mister Wong" alt="Adicionar ao&nbsp;Mister Wong" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.netscape.com/submit/?U=http%3A%2F%2Fwww.gustavohenrique.net%2Fbrogui%2F2010%2F02%2Fdjango-usando-pisa-para-converter-html-para-pdf%2F&amp;T=Django+usando+Pisa+para+converter+HTML+para+PDF" rel="nofollow" title="Adicionar ao&nbsp;Netscape"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/netscape.png" title="Adicionar ao&nbsp;Netscape" alt="Adicionar ao&nbsp;Netscape" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://reddit.com/submit?url=http%3A%2F%2Fwww.gustavohenrique.net%2Fbrogui%2F2010%2F02%2Fdjango-usando-pisa-para-converter-html-para-pdf%2F&amp;title=Django+usando+Pisa+para+converter+HTML+para+PDF" rel="nofollow" title="Adicionar ao&nbsp;reddit"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/reddit.png" title="Adicionar ao&nbsp;reddit" alt="Adicionar ao&nbsp;reddit" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.gustavohenrique.net%2Fbrogui%2F2010%2F02%2Fdjango-usando-pisa-para-converter-html-para-pdf%2F&amp;title=Django+usando+Pisa+para+converter+HTML+para+PDF" rel="nofollow" title="Adicionar ao&nbsp;Stumble Upon"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/stumbleupon.png" title="Adicionar ao&nbsp;Stumble Upon" alt="Adicionar ao&nbsp;Stumble Upon" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.technorati.com/faves?add=http%3A%2F%2Fwww.gustavohenrique.net%2Fbrogui%2F2010%2F02%2Fdjango-usando-pisa-para-converter-html-para-pdf%2F" rel="nofollow" title="Adicionar ao&nbsp;Technorati"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/technorati.png" title="Adicionar ao&nbsp;Technorati" alt="Adicionar ao&nbsp;Technorati" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://tipd.com/submit.php?url=http%3A%2F%2Fwww.gustavohenrique.net%2Fbrogui%2F2010%2F02%2Fdjango-usando-pisa-para-converter-html-para-pdf%2F" rel="nofollow" title="Adicionar ao&nbsp;Tip'd"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/tipd.png" title="Adicionar ao&nbsp;Tip'd" alt="Adicionar ao&nbsp;Tip'd" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://twitter.com/home/?status=Check+out+Django+usando+Pisa+para+converter+HTML+para+PDF+@+http%3A%2F%2Fwww.gustavohenrique.net%2Fbrogui%2F2010%2F02%2Fdjango-usando-pisa-para-converter-html-para-pdf%2F" rel="nofollow" title="Adicionar ao&nbsp;Twitter"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/twitter.png" title="Adicionar ao&nbsp;Twitter" alt="Adicionar ao&nbsp;Twitter" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http%3A%2F%2Fwww.gustavohenrique.net%2Fbrogui%2F2010%2F02%2Fdjango-usando-pisa-para-converter-html-para-pdf%2F&amp;t=Django+usando+Pisa+para+converter+HTML+para+PDF" rel="nofollow" title="Adicionar ao&nbsp;Yahoo My Web"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/yahoo.png" title="Adicionar ao&nbsp;Yahoo My Web" alt="Adicionar ao&nbsp;Yahoo My Web" /></a>
<br />
</div>
</div>
<!-- Social Bookmarks END -->
]]></content:encoded>
			<wfw:commentRss>http://www.gustavohenrique.net/brogui/2010/02/django-usando-pisa-para-converter-html-para-pdf/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Acessando BD Firebird através do KinterbasDB no Python</title>
		<link>http://www.gustavohenrique.net/brogui/2010/01/acessando-firebird-atraves-do-kinterbasdb-no-python/</link>
		<comments>http://www.gustavohenrique.net/brogui/2010/01/acessando-firebird-atraves-do-kinterbasdb-no-python/#comments</comments>
		<pubDate>Fri, 29 Jan 2010 15:00:12 +0000</pubDate>
		<dc:creator>gustavohenrique</dc:creator>
				<category><![CDATA[python]]></category>
		<category><![CDATA[firebird]]></category>

		<guid isPermaLink="false">http://www.gustavohenrique.net/brogui/?p=226</guid>
		<description><![CDATA[
KinterbasDB é uma biblioteca open source para Python que possibilita acessar banco de dados Firebird e algumas versões do Interbase.
O download pode ser feito na página do projeto.
Após o download, descompacte o pacote kinterbasdb-3.2.src.tar.gz.
Abra um terminal, entre no diretório onde o kinterbasdb foi descompactado e execute o comando python setup.py build. O script de instalação, [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.gustavohenrique.net/brogui/wp-content/uploads/2010/01/firebird-icon.gif"><img src="http://www.gustavohenrique.net/brogui/wp-content/uploads/2010/01/firebird-icon.gif" alt="firebird-icon" title="firebird-icon" width="66" height="67" class="aligncenter size-full wp-image-229" /></a></p>
<p>KinterbasDB é uma biblioteca open source para Python que possibilita acessar banco de dados Firebird e algumas versões do Interbase.<br />
O download pode ser feito na <a href="http://kinterbasdb.sourceforge.net/" target="_blank">página do projeto</a>.</p>
<p>Após o download, descompacte o pacote <code>kinterbasdb-3.2.src.tar.gz</code>.<br />
Abra um terminal, entre no diretório onde o kinterbasdb foi descompactado e execute o comando <code>python setup.py build</code>. O script de instalação, setup.py, automaticamente vai detectar as informações necessárias pelo compilador C.<br />
Se não ocorreu nenhum erro, execute o comando <code>python setup.py install</code> para instalar no diretório padrão de módulos do Python (varia de acordo com a distro).</p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">root@localhost: ~# wget http://downloads.sourceforge.net/project/kinterbasdb/kinterbasdb/kinterbasdb-3.2/kinterbasdb-3.2.src.tar.gz?use_mirror=ufpr
root@localhost: ~# tar zxvf kinterbasdb-3.2.src.tar.gz
root@localhost: ~# python setup.py build
Succeeded:
  /usr/bin/python setup.py build
root@localhost: ~# python setup.py install</pre></div></div>

<p>Para testar se foi instalado corretamente:</p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">root@localhost: ~# python -c &quot;import kinterbasdb as k; print k.__version__&quot;
(3, 2, 0, 'final', 0)
root@localhost: ~#</pre></div></div>

<p>É possível que apareça uma mensagem de erro em distros baseadas no Ubuntu:</p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">Traceback (most recent call last):
  File &quot;&lt;stdin&gt;&quot;, line 1, in &lt;module&gt;
kinterbasdb.OperationalError: (-901, 'begin transaction: \n  invalid parameter in transaction parameter block')</pre></div></div>

<p>Para corrigir esse problema é preciso usar uma outra versão do arquivo <code>__init__.py</code>.<br />
Faça o download em <a href="https://firebird.svn.sourceforge.net/svnroot/firebird/qa/trunk/kinterbasdb/__init__.py" target="_blank">https://firebird.svn.sourceforge.net/svnroot/firebird/qa/trunk/kinterbasdb/__init__.py</a> e substitua o arquivo existente no diretório <code>kinterbasdb</code>.</p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">root@localhost: ~# wget https://firebird.svn.sourceforge.net/svnroot/firebird/qa/trunk/kinterbasdb/__init__.py
root@localhost: ~# mv __init__.py /usr/lib/python2.5/site-packages/kinterbasdb/</pre></div></div>

<p>Exemplo para Firebird-2.1 em servidor Windows:</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">import</span> kinterbasdb
conn = kinterbasdb.<span style="color: black;">connect</span><span style="color: black;">&#40;</span>
    host=<span style="color: #483d8b;">'192.168.0.2'</span>,
    database=<span style="color: #483d8b;">'C:<span style="color: #000099; font-weight: bold;">\\</span>Dados<span style="color: #000099; font-weight: bold;">\\</span>meubanco.fdb'</span>,
    <span style="color: #dc143c;">user</span>=<span style="color: #483d8b;">'sysdba'</span>,
    password=<span style="color: #483d8b;">'masterkey'</span>
<span style="color: black;">&#41;</span>
cur = conn.<span style="color: black;">cursor</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
cur.<span style="color: black;">execute</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'SELECT id, nome, telefone FROM tabela'</span><span style="color: black;">&#41;</span>
<span style="color: #ff7700;font-weight:bold;">for</span> <span style="color: black;">&#40;</span><span style="color: #008000;">id</span>, nome, telefone<span style="color: black;">&#41;</span> <span style="color: #ff7700;font-weight:bold;">in</span> cur:
    <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">'ID: %s, Nome: %s, Fone: %s'</span> <span style="color: #66cc66;">%</span> <span style="color: black;">&#40;</span><span style="color: #008000;">id</span>, nome, telefone<span style="color: black;">&#41;</span></pre></div></div>

<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a><strong><em>Compartilhe esse artigo</em></strong></a>
<br />
<div class="d">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://buzz.yahoo.com/submit?submitUrl=http%3A%2F%2Fwww.gustavohenrique.net%2Fbrogui%2F2010%2F01%2Facessando-firebird-atraves-do-kinterbasdb-no-python%2F&amp;submitHeadline=Acessando+BD+Firebird+atrav%C3%A9s+do+KinterbasDB+no+Python&amp;submitSummary=" rel="nofollow" title="Adicionar ao&nbsp;Buzz"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/buzz.png" title="Adicionar ao&nbsp;Buzz" alt="Adicionar ao&nbsp;Buzz" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http%3A%2F%2Fwww.gustavohenrique.net%2Fbrogui%2F2010%2F01%2Facessando-firebird-atraves-do-kinterbasdb-no-python%2F&amp;title=Acessando+BD+Firebird+atrav%C3%A9s+do+KinterbasDB+no+Python" rel="nofollow" title="Adicionar ao&nbsp;Del.icio.us"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/delicious.png" title="Adicionar ao&nbsp;Del.icio.us" alt="Adicionar ao&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.gustavohenrique.net%2Fbrogui%2F2010%2F01%2Facessando-firebird-atraves-do-kinterbasdb-no-python%2F&amp;title=Acessando+BD+Firebird+atrav%C3%A9s+do+KinterbasDB+no+Python" rel="nofollow" title="Adicionar ao&nbsp;digg"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/digg.png" title="Adicionar ao&nbsp;digg" alt="Adicionar ao&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/sharer.php?u=http%3A%2F%2Fwww.gustavohenrique.net%2Fbrogui%2F2010%2F01%2Facessando-firebird-atraves-do-kinterbasdb-no-python%2F" rel="nofollow" title="Adicionar ao&nbsp;Facebook"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/facebook.png" title="Adicionar ao&nbsp;Facebook" alt="Adicionar ao&nbsp;Facebook" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http%3A%2F%2Fwww.gustavohenrique.net%2Fbrogui%2F2010%2F01%2Facessando-firebird-atraves-do-kinterbasdb-no-python%2F&amp;title=Acessando+BD+Firebird+atrav%C3%A9s+do+KinterbasDB+no+Python" rel="nofollow" title="Adicionar ao&nbsp;Google Bookmarks"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/google.png" title="Adicionar ao&nbsp;Google Bookmarks" alt="Adicionar ao&nbsp;Google Bookmarks" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.mister-wong.com/index.php?action=addurl&amp;bm_url=http%3A%2F%2Fwww.gustavohenrique.net%2Fbrogui%2F2010%2F01%2Facessando-firebird-atraves-do-kinterbasdb-no-python%2F&amp;bm_description=Acessando+BD+Firebird+atrav%C3%A9s+do+KinterbasDB+no+Python" rel="nofollow" title="Adicionar ao&nbsp;Mister Wong"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/misterwong.png" title="Adicionar ao&nbsp;Mister Wong" alt="Adicionar ao&nbsp;Mister Wong" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.netscape.com/submit/?U=http%3A%2F%2Fwww.gustavohenrique.net%2Fbrogui%2F2010%2F01%2Facessando-firebird-atraves-do-kinterbasdb-no-python%2F&amp;T=Acessando+BD+Firebird+atrav%C3%A9s+do+KinterbasDB+no+Python" rel="nofollow" title="Adicionar ao&nbsp;Netscape"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/netscape.png" title="Adicionar ao&nbsp;Netscape" alt="Adicionar ao&nbsp;Netscape" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://reddit.com/submit?url=http%3A%2F%2Fwww.gustavohenrique.net%2Fbrogui%2F2010%2F01%2Facessando-firebird-atraves-do-kinterbasdb-no-python%2F&amp;title=Acessando+BD+Firebird+atrav%C3%A9s+do+KinterbasDB+no+Python" rel="nofollow" title="Adicionar ao&nbsp;reddit"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/reddit.png" title="Adicionar ao&nbsp;reddit" alt="Adicionar ao&nbsp;reddit" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.gustavohenrique.net%2Fbrogui%2F2010%2F01%2Facessando-firebird-atraves-do-kinterbasdb-no-python%2F&amp;title=Acessando+BD+Firebird+atrav%C3%A9s+do+KinterbasDB+no+Python" rel="nofollow" title="Adicionar ao&nbsp;Stumble Upon"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/stumbleupon.png" title="Adicionar ao&nbsp;Stumble Upon" alt="Adicionar ao&nbsp;Stumble Upon" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.technorati.com/faves?add=http%3A%2F%2Fwww.gustavohenrique.net%2Fbrogui%2F2010%2F01%2Facessando-firebird-atraves-do-kinterbasdb-no-python%2F" rel="nofollow" title="Adicionar ao&nbsp;Technorati"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/technorati.png" title="Adicionar ao&nbsp;Technorati" alt="Adicionar ao&nbsp;Technorati" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://tipd.com/submit.php?url=http%3A%2F%2Fwww.gustavohenrique.net%2Fbrogui%2F2010%2F01%2Facessando-firebird-atraves-do-kinterbasdb-no-python%2F" rel="nofollow" title="Adicionar ao&nbsp;Tip'd"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/tipd.png" title="Adicionar ao&nbsp;Tip'd" alt="Adicionar ao&nbsp;Tip'd" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://twitter.com/home/?status=Check+out+Acessando+BD+Firebird+atrav%C3%A9s+do+KinterbasDB+no+Python+@+http%3A%2F%2Fwww.gustavohenrique.net%2Fbrogui%2F2010%2F01%2Facessando-firebird-atraves-do-kinterbasdb-no-python%2F" rel="nofollow" title="Adicionar ao&nbsp;Twitter"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/twitter.png" title="Adicionar ao&nbsp;Twitter" alt="Adicionar ao&nbsp;Twitter" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http%3A%2F%2Fwww.gustavohenrique.net%2Fbrogui%2F2010%2F01%2Facessando-firebird-atraves-do-kinterbasdb-no-python%2F&amp;t=Acessando+BD+Firebird+atrav%C3%A9s+do+KinterbasDB+no+Python" rel="nofollow" title="Adicionar ao&nbsp;Yahoo My Web"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/yahoo.png" title="Adicionar ao&nbsp;Yahoo My Web" alt="Adicionar ao&nbsp;Yahoo My Web" /></a>
<br />
</div>
</div>
<!-- Social Bookmarks END -->
]]></content:encoded>
			<wfw:commentRss>http://www.gustavohenrique.net/brogui/2010/01/acessando-firebird-atraves-do-kinterbasdb-no-python/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
