<?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; firebird</title>
	<atom:link href="http://www.gustavohenrique.net/brogui/tag/firebird/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>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>
