Skip to content
Snippets Groups Projects
Commit 1a1d9a68 authored by Pietro Cavassin's avatar Pietro Cavassin
Browse files

insert does not alter temporary tables anymore

parent cbbf0f53
No related branches found
No related tags found
No related merge requests found
......@@ -51,7 +51,8 @@ def temporary_data(connection, file_name, table, year, offset=2,
ttable.create(bind=connection)
table.populate_temporary(ttable, file_name, header, year, delimiters, null, offset, bind=connection)
table.apply_derivatives(ttable, ttable.columns.keys(), year, bind=connection)
if len(table._derivatives) != 0:
table.apply_derivatives(ttable, ttable.columns.keys(), year, bind=connection)
table.add_pk_to_temporary(ttable, bind=connection)
return ttable
......@@ -68,6 +69,7 @@ def insert(file_name, table, year, offset=2, delimiters=[';', '\\n', '"'], null=
ttable = temporary_data(connection, file_name, table, year, offset, delimiters, null)
table.insert_from_temporary(ttable, bind=connection)
ttable.drop()
trans.commit()
......
......@@ -181,7 +181,7 @@ class DatabaseTable(Table):
logger.info("Acquiring temporary table with name '%s'", name)
logger.debug("Temporary table '%s' with list of extra columns %s", name, header_columns)
ttable = Table(name, self.metadata, prefixes=['TEMPORARY'], schema='tmp')
ttable = Table(name, self.metadata, schema='sys')
for target in self._protocol.get_targets():
try:
......@@ -610,7 +610,7 @@ class DatabaseTable(Table):
trans = connection.begin()
ttable = Table('t_' + self.name, self.metadata, *(temp_pk_columns + temp_columns),
schema="tmp", prefixes=["TEMPORARY"])
schema="sys")
ttable.create(bind=connection)
ttable.schema = None
......@@ -979,7 +979,8 @@ class DatabaseTable(Table):
# Run derivatives
ttable = self.create_temporary_mirror(year, bind)
self.apply_derivatives(ttable, ttable.columns.keys(), year, bind, dbonly=True)
if len(ttable._derivatives) != 0:
self.apply_derivatives(ttable, ttable.columns.keys(), year, bind, dbonly=True)
self.update_from_temporary(ttable, ttable.columns.keys(), bind)
def get_relations(self, table):
......
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