[1d802c]: / Code / DataPrep / adt_transfer.py

Download this file

28 lines (22 with data), 882 Bytes

 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
# This script executes the adt transfer sql query in Michael's database to create the transfer table
# and exports the table as a csv file
import sys
sys.path.insert(0, '../')
import sqlite3
import pandas as pd
from utils.db_utils import create_connection, create_table, export_table
def main():
database = "P:/dihi_qi/data_pipeline/db/data_pipeline.db"
transfer_qry = open('./adt_transfer.sql', 'r').read()
# create a database connection
conn = create_connection(database)
if conn is not None:
# create adult_decomp_adt_transfer table
create_table(conn, transfer_qry)
else:
print("Error! cannot create the database connection.")
#export the table to a csv file
export_table(conn, 'adult_decomp_adt_transfer', '../../Data/Processed/adult_decomp_adt_transfer.csv')
conn.close()
if __name__ == '__main__':
main()