def query_sql(db_path, table_name):
"""
Uses pandas to pull data from our sqlite database
args
db_path (str) : location of the database
table_name (str) : name of the table we want
returns
data (pd.DataFrame) :
"""
print('Pulling data for table {} from {}'.format(db_path, table_name))
# connect to our database
conn = sqlite3.connect(db_path)
# pull data by selecting the entire table
data = pd.read_sql(sql='SELECT * from '+str(table_name), con=conn)
data.set_index('index', drop=True, inplace=True)
# close the connection
conn.close()
return data
make_dataset.py 文件源码
python
阅读 32
收藏 0
点赞 0
评论 0
评论列表
文章目录