Manager
Blockchain data collection Index /
src /
data_collection /
App /
Db /
Manager
Auto-generated documentation for src.data_collection.app.db.manager module.
DatabaseManager
Manage the PostgreSQL connection and CRUD operations.
https://magicstack.github.io/asyncpg/current/usage.html
Signature
DatabaseManager().connect
Connects to the PostgreSQL database.
Signature
DatabaseManager().disconnect
Disconnect from PostgreSQL
Signature
DatabaseManager().get_block
Get the block data with a given identifier from the block table.
Notes
If block_identifier is None, returns the latest block data in the table.
Returns
Optional[dict[str,Any]] - if available returns block data as a dict, otherwise returnsNone
Signature
async def get_block(
self, block_identifier: Optional[Union[str, int]] = None
) -> Optional[dict[str, Any]]:
...
DatabaseManager().insert_block
Insert block data into
Signature
async def insert_block(
self,
block_number: int,
block_hash: str,
nonce: str,
difficulty: int,
gas_limit: int,
gas_used: int,
timestamp: datetime,
miner: str,
parent_hash: str,
block_reward: float,
uncles: list[str],
):
...
DatabaseManager().insert_contract
Insert contract data into
Signature
DatabaseManager().insert_contract_supply_change
Insert token contract supply change data into
Signature
async def insert_contract_supply_change(
self, address: str, amount_changed: int, transaction_hash: str
):
...
DatabaseManager().insert_internal_transaction
Insert internal transaction data into
Signature
async def insert_internal_transaction(
self,
transaction_hash: str,
from_address: str,
to_address: str,
value: float,
gas_limit: float,
gas_used: int,
input_data: str,
call_type: str,
):
...
DatabaseManager().insert_nft_transfer
Insert nft transfer data into
Signature
async def insert_nft_transfer(
self,
transaction_hash: str,
log_index: int,
address: str,
from_address: str,
to_address: str,
token_id: int,
):
...
DatabaseManager().insert_pair_contract
Insert pair contract data into
Signature
async def insert_pair_contract(
self,
address: str,
token0_address: str,
token1_address: str,
reserve0: int,
reserve1: int,
factory: str,
):
...
DatabaseManager().insert_pair_liquidity_change
Insert pair liquidity change data into
Signature
async def insert_pair_liquidity_change(
self, address: str, amount0: int, amount1: int, transaction_hash: str
):
...
DatabaseManager().insert_token_contract
Insert token contract data into
Signature
async def insert_token_contract(
self,
address: str,
symbol: str,
name: str,
decimals: int,
total_supply: int,
token_category: str,
):
...
DatabaseManager().insert_transaction
Insert transaction data into
Signature
async def insert_transaction(
self,
transaction_hash: str,
block_number: int,
from_address: str,
to_address: str,
value: float,
transaction_fee: float,
gas_price: float,
gas_limit: int,
gas_used: int,
is_token_tx: bool,
input_data: str,
):
...
DatabaseManager().insert_transaction_logs
Insert transaction logs data into