Skip to content

Commit

Permalink
commit all indexes in a single transaction
Browse files Browse the repository at this point in the history
  • Loading branch information
floptical committed Apr 5, 2024
1 parent 0e94fba commit 65a2862
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions databridge_etl_tools/carto/carto_.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,17 +277,18 @@ def create_table(self):
self.logger.info('Temp table created successfully.\n')

def create_indexes(self):
self.logger.info('Creating indexes on {}: {}'.format(
self.logger.info('\nCreating indexes on {}: {}'.format(
self.temp_table_name,
self.index_fields)
)

indexes = self.index_fields.split(',')
stmt = ''
index_stmt = 'BEGIN; '
for indexes_field in indexes:
stmt += 'CREATE INDEX {table}_{field} ON "{table}" ("{field}");\n'.format(table=self.temp_table_name,
index_stmt += 'CREATE INDEX {table}_{field} ON "{table}" ("{field}");\n'.format(table=self.temp_table_name,
field=indexes_field)
self.execute_sql(stmt)
index_stmt += 'COMMIT;'
self.execute_sql(index_stmt)
self.logger.info('Indexes created successfully.\n')

def extract(self):
Expand Down

0 comments on commit 65a2862

Please sign in to comment.