def insert_global_covid(): global_daily_df, global_cumul_df = crawling_global_covid() # Insert data - MongoDB, database name: 'GlobalCOVID' conn = conn_db() global_daily_collection = conn.GlobalCOVID.daily global_cumul_collection = conn.GlobalCOVID.cumul print(datetime.now()) print( "insert_global_covid daily Updated: ", insert_data(global_daily_df, global_daily_collection, 'date', 'country', check=True)) print( "insert_global_covid cumul Updated: ", insert_data(global_cumul_df, global_cumul_collection, 'date', 'country', check=True)) conn.close() return True
def main(): conn, cur = functions.connect() status = True functions.print_menu() while status: choice = int(input('Choice: ')) if choice == 1: functions.create_table(conn, cur, 'teachers') elif choice == 2: functions.insert_data(conn, cur, 'teachers') elif choice == 3: keys = input('SELECT BY: ') records = functions.select_from_db(conn, cur, 'teachers', keys) functions.print_selected_data(records, keys) elif choice == 4: records = functions.select_from_db(conn, cur, 'teachers') functions.print_selected_data(records) elif choice == 5: functions.disconnect(conn, cur) break functions.print_menu()
def insert_validate_FBProphet_data(ADJ_CONST=1.): print("ADJ_CONST(R0): ", ADJ_CONST) try: val_df, ADJ_CONST = validate_FBProphet_model(ADJ_CONST) conn = conn_db() validate_FBProphet_collection = conn.DomesticCOVID.validate_FBProphet validate_FBProphet_collection.drop() col_list = val_df.columns doc_list = list() insert_data(val_df, validate_FBProphet_collection, check=False) conn.close() return True, ADJ_CONST except: print("Error Occured: insert_validate_FBProphet_data Function") return False
def insert_domestic_covid_cumul(): domestic_cumul_df = crawling_domestic_covid_cumul() conn = conn_db() domestic_cumul_collection = conn.DomesticCOVID.domestic_cumul print( "insert_domestic_covid_cumul Updated: ", insert_data(domestic_cumul_df, domestic_cumul_collection, 'date', check=True)) conn.close() return True
import json from functions import db_connect, get_api_call, get_collection, insert_data url = "https://api.yelp.com/v3/businesses/search?term=restaurants&location=Dallas&limit=50" payload = {} response = get_api_call(url, payload) businesses = json.loads(response.text)['businesses'] client = db_connect() id_list = insert_data(client, 'Businesses', businesses) print(id_list) for id in id_list: url = "https://api.yelp.com/v3/businesses/" + str(id) + "/reviews" payload = {} response = get_api_call(url, payload) reviews = json.loads(response.text)['reviews'] id_list = insert_data(client, 'Reviews', reviews)
parser.add_argument( "-d", "--decrypt", action="store_true", help="Whether to decrypt the file, only -e or -d can be specified.") args = parser.parse_args() secret = SECRET_KEY passw = input( 'Please provide the master password to start using the password manager: ') if passw == secret: file = "backup.sql" if args.view: functions.view_data() elif args.insert: functions.insert_data() elif args.update == 'username': functions.update_data(functions.data, 0) elif args.update == 'password': functions.update_data(functions.data, 1) elif args.update == 'email': functions.update_data(functions.data, 2) elif args.reset: functions.reset_data() elif args.reset_all: functions.reset_all_data() elif args.copy_password: functions.copy_to_clipboard()
def main(): f.create_db() f.create_table() f.insert_data()