0
I am making a recording in the database (Postgresql) with Python, I use a base on .txt. 
Problem: At the base have some records are blank, and is giving error at the time of recording, occurs in the Date field. would like to know how do I put a if or a Exception to fill with by Ex: 00-00-0000 in such cases. 
 
I can even put the whole table on Var Char, but 
 data_ingresso = valores[12] I need to record as Data same, because I will account with her in the bank.
In case the structure of the question is bad I can try to improve.
import psycopg2
con = psycopg2.connect( database='cap',host='localhost', user='postgres', password='**********')
cur = con.cursor()
ref_arquivo = open("C:/Users/br0151338587/Desktop/!Alertas/ampla_Novo_Tempo_Ordens_GA.txt",'r')
input("Conexão OK - Enter para continuar")
sql = 'truncate "tb_ordens_ga"'
cur.execute(sql)
for linha in ref_arquivo:
    linha = linha.replace("'","")
    linha = linha.replace('"','')
    valores = linha.split("|")
    numero_ordem = valores[0]
    data_exec_visita = valores[1]
    data_estado_format = valores[2]
    numero_cliente = valores[3]
    cliente = valores[4]
    endereco = endereco = valores[5]
    telefone = valores[6]
    bairro = valores[7]
    municipio = valores[8]
    des_servico = valores[9]
    descricao_etapa = valores[10]
    descricao_estado = valores[11]
    data_ingresso = valores[12]
    observacao_executante = valores[13]
    observacao_atendente = valores[14]
    sql = 'insert into "public"."tb_ordens_ga"("numero_ordem","data_exec_visita","data_estado_format","numero_cliente","cliente","endereco","telefone","bairro",' \
      '"municipio","des_servico","descricao_etapa","descricao_estado","data_ingresso","observacao_executante","observacao_atendente"'') \
       values('+"'"+numero_ordem+"'"+', '+"'"+data_exec_visita+"'"+', '+"'"+data_estado_format+"'"+', '+\
      "'"+numero_cliente+"'"+', '+"'"+cliente+"'"+', '+"'"+endereco+"'"+', '+"'"+telefone+"'"+', '+"'"+bairro+"'"+', '+"'"+municipio+"'"\
      ', '+"'"+des_servico+"'"+', '+"'"+descricao_etapa+"'"+', '+"'"+descricao_estado+"'"+', '+"'"+data_ingresso+"'"+\
      ', '+"'"+observacao_executante+"'"+', '+"'"+observacao_atendente+"'"+')'
    cur.execute(sql)
    con.commit()
ref_arquivo.close()
con.close()
						
You may not want to record a date of "0000-00-00" in the bank: that day there is no in the Gregorian calendar. I marked the question as a duplicate of one where I deal with the question in detail, even though the question is not identical.
– jsbueno