Skip to content

Commit

Permalink
Add old_index_value to index_sql (#88)
Browse files Browse the repository at this point in the history
* tweak to give index_sql awareness of old_index_value so that we have more control over the new_index_value

* address linter complaints
  • Loading branch information
jtung1027 authored Jan 24, 2025
1 parent c5181f8 commit 3669be4
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
3 changes: 1 addition & 2 deletions druzhba/mssql.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

import pymssql

from druzhba.config import CONFIG_DIR
from druzhba.table import TableConfig, load_query
from druzhba.table import TableConfig


class MSSQLTableConfig(TableConfig):
Expand Down
3 changes: 1 addition & 2 deletions druzhba/mysql.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
import pymysql.cursors
from pymysql import FIELD_TYPE as ft

from druzhba.config import CONFIG_DIR
from druzhba.table import TableConfig, load_query
from druzhba.table import TableConfig


class MysqlTypes:
Expand Down
3 changes: 1 addition & 2 deletions druzhba/postgres.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
import psycopg2.extensions
import psycopg2.extras

from druzhba.config import CONFIG_DIR
from druzhba.table import TableConfig, load_query
from druzhba.table import TableConfig

psycopg2.extensions.register_type(psycopg2.extensions.UNICODE)
psycopg2.extensions.register_type(psycopg2.extensions.UNICODEARRAY)
Expand Down
9 changes: 7 additions & 2 deletions druzhba/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,12 @@ def run_template_data(self):
"old_index_value": self.old_index_value,
}

@property
def index_template_data(self):
return {
"old_index_value": self.old_index_value
}

def _load_old_index_value(self):
"""Sets and gets the index_value property, retrieved from Redshift
Expand Down Expand Up @@ -660,8 +666,7 @@ def new_index_value(self):
query = template.render(
db=self.db_template_data,
table=self.table_template_data,
# Cannot include the run template data
# here because we do not know the index values yet
index=self.index_template_data,
)
self._new_index_value = self.query_fetchone(query)["index_value"]

Expand Down

0 comments on commit 3669be4

Please sign in to comment.