From 0264c1969d56759e650f8db286808579d9151f7c Mon Sep 17 00:00:00 2001 From: hugo Date: Wed, 14 Feb 2024 11:46:49 +0200 Subject: [PATCH] introducing os for the db path --- portfolio.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) mode change 100644 => 100755 portfolio.py diff --git a/portfolio.py b/portfolio.py old mode 100644 new mode 100755 index 06d22a4..8f4ebb9 --- a/portfolio.py +++ b/portfolio.py @@ -1,3 +1,6 @@ +#!/usr/bin/env python3 + +import os import json import sqlite3 @@ -20,6 +23,7 @@ import requests +db_file = os.path.expanduser('~/Documents/portfolio.db') # Define a function to create or connect to the database def create_or_connect_db(db_name): @@ -70,7 +74,7 @@ def fetch_coin_prices(session, coin_codes): return json.loads(response.text) def main(): - conn, cursor = create_or_connect_db('portfolio.db') + conn, cursor = create_or_connect_db(db_file) all_coins = fetch_portfolio_data(cursor) conn.close()