-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsupport_functions.py
32 lines (27 loc) · 1.1 KB
/
support_functions.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import argparse
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
from database_setup import Base
def get_input_args():
"""Returns input arguments for main file execution"""
parser = argparse.ArgumentParser()
parser.add_argument('--text_notification', '-t', type = str, default = 'False',
help = 'Argument to enable text message notifications. "\
"Possible values are "True" and "False"')
parser.add_argument('--currency', '-c', type = str, default = 'DOGE',
help = 'Argument for currency which will be scraped')
return parser.parse_args()
def get_startpage_url(currency):
"""Returns url of currency traded against Bitcoin"""
currency_url = "https://coinsquare.com/trade?pair=" + currency + "-BTC"
return currency_url
def create_session():
"""Returns a session for database operations"""
try:
engine = create_engine('sqlite:///doge_prices_volumes.db')
Base.metadata.bind = engine
DBsession = sessionmaker(bind=engine)
session = DBsession()
except Exception as e:
print(e)
return session