Created
October 19, 2017 17:01
-
-
Save tiagocardosos/e561ab3e443b199b5b2e6d3ee31fcfbf to your computer and use it in GitHub Desktop.
Python & Firebird
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Importando o Driver de conexao do Firebird | |
import fdb | |
import os.path | |
# Conecta ao Firebird | |
con = fdb.connect(dsn='X.X.X.X:/Caminho/Base.GDB', user='user', password='senha') | |
# Executando SQL | |
cursor = con.cursor() # cria cursor | |
sql='SELECT CODIGO FROM TABLIN' | |
cursor.execute(sql) | |
result = cursor.fetchall() | |
# Imprime resultado na tela | |
#print (result) | |
# Define o caminho do arquivo usado | |
# Cria o arquivo Texto no diretorio do programa | |
arquivo = open ('teste.txt', 'w') | |
# Escreve no arquivo | |
arquivo.write (str(result)) | |
# Fecha o arquivo | |
arquivo.close() | |
# Fecha conexão com o Firebird | |
con.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment