Skip to content
Snippets Groups Projects
Commit 2d1e28e7 authored by Santiago Said's avatar Santiago Said
Browse files

soluciona hardcode de dbname

fixes #1
parent 95676b7c
No related branches found
No related tags found
No related merge requests found
......@@ -57,8 +57,8 @@ class padron_import_(osv.osv_memory):
files_extracted.append(out_path + '/' + name)
assert len(files_extracted) == 1, "Expected only a file compressed, get: " + str(len(files_extracted))
txt_path = "'" + files_extracted[0] + "'"
new_cr = cr.dbname
cursor = pooler.get_db(new_cr).cursor() # Obtengo un nuevo cursor a partir del cursor existente
dbname = cr.dbname
cursor = pooler.get_db(dbname).cursor() # Obtengo un nuevo cursor a partir del cursor existente
try:
_logger.info('[AGIP] Creando tabla temporal')
cursor.execute("DROP TABLE IF EXISTS t")
......@@ -83,7 +83,7 @@ class padron_import_(osv.osv_memory):
cursor.commit()
_logger.info('[AGIP] Copiando del csv a tabla temporal')
retcode = call(["psql", "--dbname=agip", "--command=\copy t(create_date,from_date,to_date,vat,u1,u2,u3,percentage_perception,percentage_retention,u4,u5,name_partner) FROM " + txt_path + " WITH DELIMITER ';' NULL '' CSV QUOTE E'\b' ENCODING 'latin1'"], stderr=STDOUT)
retcode = call(["psql", "--dbname=" + dbname, "--command=\copy t(create_date,from_date,to_date,vat,u1,u2,u3,percentage_perception,percentage_retention,u4,u5,name_partner) FROM " + txt_path + " WITH DELIMITER ';' NULL '' CSV QUOTE E'\b' ENCODING 'latin1'"], stderr=STDOUT)
assert retcode == 0, "Call to psql subprocess copy command returned: " + str(retcode)
try:
......@@ -119,9 +119,9 @@ class padron_import_(osv.osv_memory):
z.extract(name, out_path)
files_extracted.append(out_path + '/' + name)
_logger.info('[ARBA] Files extracted: ' + str(len(files_extracted)))
assert len(files_extracted) == 2, "Expected two files compressed, get: " + str(len(files_extracted))
new_cr = cr.dbname
cursor = pooler.get_db(new_cr).cursor() # Obtengo un nuevo cursor a partir del cursor existente
assert len(files_extracted) == 2, "Expected two files compressed, got: " + str(len(files_extracted))
dbname = cr.dbname
cursor = pooler.get_db(dbname).cursor() # Obtengo un nuevo cursor a partir del cursor existente
for file_name in files_extracted:
txt_path = "'" + file_name + "'"
if 'Ret' in file_name:
......@@ -129,7 +129,7 @@ class padron_import_(osv.osv_memory):
# copiar a postgresql padron_arba_retention
self.create_temporary_table(cursor)
_logger.info('[ARBA] Ret - Copiando a tabla temporal')
retcode = call(["psql", "--dbname=db", "--command=\copy t(regimen,create_date,from_date,to_date,vat,multilateral,u1,u2,percentage,u3,u4) FROM " + txt_path + " WITH DELIMITER ';' NULL '' "], stderr=STDOUT)
retcode = call(["psql", "--dbname=" + dbname, "--command=\copy t(regimen,create_date,from_date,to_date,vat,multilateral,u1,u2,percentage,u3,u4) FROM " + txt_path + " WITH DELIMITER ';' NULL '' "], stderr=STDOUT)
assert retcode == 0, 'Call expected return 0'
try:
cursor.execute("DELETE FROM padron_arba_retention")
......@@ -156,7 +156,7 @@ class padron_import_(osv.osv_memory):
if 'Per' in file_name:
self.create_temporary_table(cursor)
_logger.info('[ARBA] Per - Copiando a tabla temporal')
retcode = call(["psql", "--dbname=db", "--command=\copy t(regimen,create_date,from_date,to_date,vat,multilateral,u1,u2,percentage,u3,u4) FROM " + txt_path + " WITH DELIMITER ';' NULL '' "], stderr=STDOUT)
retcode = call(["psql", "--dbname=" + dbname, "--command=\copy t(regimen,create_date,from_date,to_date,vat,multilateral,u1,u2,percentage,u3,u4) FROM " + txt_path + " WITH DELIMITER ';' NULL '' "], stderr=STDOUT)
assert retcode == 0, 'Call expected return 0'
try:
cursor.execute("DELETE FROM padron_arba_perception")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment