#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Starter code for assignment 13. @author: azs """ import sqlite3 as db import pandas as pd # set some options to display enough columns of output pd.set_option('display.width', 320) pd.set_option('display.max_columns',10) # These queries will help you discover the database schema (structure). example_0a = '''SELECT name FROM sqlite_master''' example_0b = '''pragma table_info(clients)''' example_0c = '''pragma table_info(trades)''' example_0d = '''pragma table_info(price_history)''' # This is an example query that you can use to get started: ## QUERY 00 SHOW ALL CLIENTS IN DATABASE sql_00 = ''' SELECT * FROM clients ''' ################################################################################ def run_query(sql): # obtain a database connection: con=db.connect("./portfolio.db") # Ask Pandas to run a query and return the resulting data set as a pd.DataFrame object: df = pd.read_sql(sql, con=con) return df ################################################################################ if __name__ == '__main__': # Ask Pandas to run a query and return the resulting data set as a pd.DataFrame object: print(run_query(sql_00))