Skip to content

Commit

Permalink
minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
harisang committed Dec 11, 2024
1 parent e392d02 commit 6b15638
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion src/data_sync/sync_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ async def sync_data_to_db( # pylint: disable=too-many-arguments
for i, _ in enumerate(block_range_list):
start_block = block_range_list[i][0]
end_block = block_range_list[i][1]
table_name = type_of_data + "_data_" + network + "_" + months_list[i]
network_name = "ethereum" if network == "mainnet" else network
table_name = type_of_data + "_data_" + network_name + "_" + months_list[i]
block_range = BlockRange(block_from=start_block, block_to=end_block)
log.info(
f"About to process block range ({start_block}, {end_block}) for month {months_list[i]}"
Expand All @@ -67,6 +68,27 @@ async def sync_data_to_db( # pylint: disable=too-many-arguments
else:
data = orderbook.get_order_data(block_range, config)
log.info("SQL query successfully executed. About to update analytics table.")

# ###############
# # we first create the corresponding table in case it does not exist yet.
# analytics_engine = OrderbookFetcher.pg_engine(OrderbookEnv.ANALYTICS)
# if type_of_data == "batch":
# sql_file_path = "queries/orderbook/create_batch_table.sql"
# else:
# sql_file_path = "queries/orderbook/create_order_table.sql"
# with open(sql_file_path, "r") as file:
# sql_commands_prelim = file.read()
# sql_commands = sql_commands_prelim.replace("table_name", table_name)
# print(sql_commands)
# # Connect to the database and execute the command
# # Execute the SQL commands
# with analytics_engine.connect() as connection:
# for statement in sql_commands.split(";"): # Split commands by semicolon
# statement = statement.strip()
# if statement: # Skip empty statements
# connection.execute(text(statement))
# ###############

data.to_sql(
table_name,
OrderbookFetcher.pg_engine(OrderbookEnv.ANALYTICS),
Expand Down

0 comments on commit 6b15638

Please sign in to comment.