mirror of
https://github.com/autistic-symposium/blockchain-data-engineering-toolkit.git
synced 2025-05-16 21:52:39 -04:00
first commit
This commit is contained in:
commit
bb17a2a56e
29 changed files with 1238 additions and 0 deletions
29
token-scanner-api/src/utils/db_utils.py
Normal file
29
token-scanner-api/src/utils/db_utils.py
Normal file
|
@ -0,0 +1,29 @@
|
|||
# -*- encoding: utf-8 -*-
|
||||
# utils/furnish_db.py
|
||||
# Furnish the database with data.
|
||||
|
||||
import pymongo
|
||||
import src.utils.os_utils as os_utils
|
||||
|
||||
def run():
|
||||
|
||||
url = "mongodb://localhost:27017/"
|
||||
|
||||
client = pymongo.MongoClient(url)
|
||||
db = client.test
|
||||
database_name = client["balances"]
|
||||
collection_name = database_name["balances"]
|
||||
|
||||
|
||||
filename = "./balance.json"
|
||||
data = os_utils.open_json(filename)
|
||||
|
||||
|
||||
result = []
|
||||
for wallet, balance in data.items():
|
||||
result.append({"wallet": wallet, "balance": balance})
|
||||
|
||||
collection_name.insert_many(result)
|
||||
|
||||
def populate_db():
|
||||
pass
|
Loading…
Add table
Add a link
Reference in a new issue