installed prisma for py
This commit is contained in:
parent
3dd7e315c7
commit
efbe12f173
1
.env
1
.env
@ -38,4 +38,3 @@ SUBSCRIPTION_ID='2217755'
|
||||
# Prisma supports the native connection string format for PostgreSQL, MySQL, SQLite, SQL Server, MongoDB and CockroachDB.
|
||||
# See the documentation for all the connection string options: https://pris.ly/d/connection-strings
|
||||
|
||||
DATABASE_URL="postgresql://johndoe:randompassword@localhost:5432/mydb?schema=public"
|
@ -405,6 +405,15 @@ app = init_app()
|
||||
# Convert Flask app to ASGI
|
||||
asgi_app = WsgiToAsgi(app)
|
||||
|
||||
async def restartable_task(task_func, *args, **kwargs):
|
||||
while True:
|
||||
try:
|
||||
await task_func(*args, **kwargs)
|
||||
except Exception as e:
|
||||
logging.error(f"Error in task {task_func.__name__}: {e}")
|
||||
await telegram_utils.send_telegram_message(f"Error in task {task_func.__name__}: {e}")
|
||||
await asyncio.sleep(5) # Wait before retrying
|
||||
|
||||
async def main():
|
||||
global bot, PROCESSING_LOG, pk
|
||||
|
||||
@ -413,10 +422,11 @@ async def main():
|
||||
await telegram_utils.send_telegram_message("Solana Agent Started. Connecting to mainnet...")
|
||||
|
||||
# Start the log processor
|
||||
asyncio.create_task(watch_for_new_logs())
|
||||
asyncio.create_task(restartable_task(watch_for_new_logs))
|
||||
# process_transaction
|
||||
|
||||
if DO_WATCH_WALLET:
|
||||
asyncio.create_task(restartable_task(SAPI.wallet_watch_loop))
|
||||
await SAPI.wallet_watch_loop()
|
||||
|
||||
def run_asyncio_tasks():
|
||||
|
@ -1,10 +1,11 @@
|
||||
import os
|
||||
import asyncio
|
||||
from pathlib import Path
|
||||
from .storage import store_transaction
|
||||
from .storage import store_transaction, prisma_client
|
||||
from .SolanaAPI import SolanaAPI
|
||||
|
||||
LOG_DIRECTORY = "path/to/log/directory"
|
||||
FILE_MASK = "*.log"
|
||||
LOG_DIRECTORY = "logs"
|
||||
FILE_MASK = "wh_*.json"
|
||||
|
||||
async def process_log_file(file_path):
|
||||
# Read the file and extract transaction data
|
||||
@ -22,8 +23,18 @@ async def process_log_file(file_path):
|
||||
solana_signature = "extracted_solana_signature"
|
||||
details = {}
|
||||
|
||||
# Store the transaction
|
||||
await store_transaction(wallet_id, transaction_type, sell_currency, sell_amount, sell_value, buy_currency, buy_amount, buy_value, solana_signature, details)
|
||||
# Process the webhook data
|
||||
solana_api = SolanaAPI()
|
||||
transaction_data = await solana_api.process_wh(data)
|
||||
|
||||
# Check if the transaction already exists
|
||||
existing_transaction = await prisma_client.transaction.find_first(
|
||||
where={'solana_signature': solana_signature}
|
||||
)
|
||||
|
||||
if not existing_transaction:
|
||||
# Store the transaction if it doesn't exist
|
||||
await store_transaction(wallet_id, transaction_type, sell_currency, sell_amount, sell_value, buy_currency, buy_amount, buy_value, solana_signature, details)
|
||||
|
||||
# Rename the file to append '_saved'
|
||||
new_file_path = file_path.with_name(file_path.stem + "_saved" + file_path.suffix)
|
||||
|
@ -355,3 +355,5 @@ def get_latest_log_file(wh:bool):
|
||||
except Exception as e:
|
||||
utils.log.error(f"Error fetching latest log file: {e}")
|
||||
return None
|
||||
|
||||
export = init_app
|
@ -32,11 +32,12 @@ pip-compile requirements.in
|
||||
# Optionally, update your environment
|
||||
# pip-sync requirements.txt
|
||||
|
||||
echo "Requirements have been updated in requirements.txt"
|
||||
prisma on py:
|
||||
//#python -m prisma generate
|
||||
pip install -U prisma
|
||||
prisma db push
|
||||
|
||||
|
||||
|
||||
max ammount on FATGF gives error:
|
||||
ERROR:error_logger:<b>Swap Follow Error:</b>
|
||||
Program log: Instruction: Transfer", "Program log: Error: insufficient funds", "Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA consumed 4300 of 1363889 compute units"
|
||||
|
||||
# PROD deployment:
|
||||
gunicorn -w 4 -k uvicorn.workers.UvicornWorker app:asgi_app --bind 0.0.0.0:3001 --log-level info
|
8
package-lock.json
generated
8
package-lock.json
generated
@ -8,7 +8,7 @@
|
||||
"name": "kevin-ai",
|
||||
"version": "1.0.0",
|
||||
"dependencies": {
|
||||
"@prisma/client": "^5.16.1",
|
||||
"@prisma/client": "^5.22.0",
|
||||
"axios": "^1.7.2",
|
||||
"body-parser": "^1.20.2",
|
||||
"dotenv": "^16.4.5",
|
||||
@ -26,9 +26,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@prisma/client": {
|
||||
"version": "5.16.1",
|
||||
"resolved": "https://registry.npmjs.org/@prisma/client/-/client-5.16.1.tgz",
|
||||
"integrity": "sha512-wM9SKQjF0qLxdnOZIVAIMKiz6Hu7vDt4FFAih85K1dk/Rr2mdahy6d3QP41K62N9O0DJJA//gUDA3Mp49xsKIg==",
|
||||
"version": "5.22.0",
|
||||
"resolved": "https://registry.npmjs.org/@prisma/client/-/client-5.22.0.tgz",
|
||||
"integrity": "sha512-M0SVXfyHnQREBKxCgyo7sffrKttwE6R8PMq330MIUF0pTwjUhLbW84pFDlf06B27XyCR++VtjugEnIHdr07SVA==",
|
||||
"hasInstallScript": true,
|
||||
"engines": {
|
||||
"node": ">=16.13"
|
||||
|
@ -12,7 +12,7 @@
|
||||
"NODE_ENV": "demo"
|
||||
},
|
||||
"dependencies": {
|
||||
"@prisma/client": "^5.16.1",
|
||||
"@prisma/client": "^5.22.0",
|
||||
"axios": "^1.7.2",
|
||||
"body-parser": "^1.20.2",
|
||||
"dotenv": "^16.4.5",
|
||||
|
@ -2,6 +2,19 @@ generator client {
|
||||
provider = "prisma-client-js"
|
||||
}
|
||||
|
||||
datasource db {
|
||||
provider = "mysql"
|
||||
url = "mysql://root:Zelen0ku4e@192.168.0.10:3306/trader"
|
||||
//env("DATABASE_URL")
|
||||
}
|
||||
|
||||
|
||||
generator py {
|
||||
provider = "prisma-client-py"
|
||||
recursive_type_depth = 5
|
||||
}
|
||||
|
||||
|
||||
model User {
|
||||
id Int @id @default(autoincrement())
|
||||
username String @unique
|
||||
@ -76,11 +89,6 @@ model Transaction {
|
||||
timestamp DateTime @default(now())
|
||||
}
|
||||
|
||||
datasource db {
|
||||
provider = "mysql"
|
||||
url = "mysql://root:Zelen0ku4e@192.168.0.10:3306/trader"
|
||||
}
|
||||
|
||||
model Timeseries {
|
||||
id Int @id @default(autoincrement())
|
||||
timestamp DateTime @default(now())
|
||||
|
Loading…
x
Reference in New Issue
Block a user