예제 #1
0
#!/usr/bin/python

import sch_client
import json
import cx_Oracle
import os
from datetime import datetime
from copy import copy

__location__ = os.path.realpath(os.path.join(os.getcwd(), os.path.dirname(__file__)))
sch_client.init_logging(__location__, "sync_push_banner")
sch_client.printme("------ Begin sync_push_banner ------")
config = json.load(open(os.path.join(__location__, "config.json")))
api = sch_client.API(config["uri"], config["key"], config["secret"])
connection = cx_Oracle.connect(config["db_connection"])
cursor = connection.cursor()
verbose = False

# Proxy for SPRIDEN table in Banner. View containing relevant students
resident_select = """
SELECT * FROM acadmgr.sch_student_demo WHERE acadmgr.sch_student_demo.STUDENTID = $%$id$%$
"""

room_assignment_dates_select = """
SELECT * FROM SLRASCD WHERE SLRASCD_TERM_CODE = $%$TERM$%$ AND SLRASCD_ASCD_CODE = $%$ASSIGN_CODE$%$
"""

meal_assignment_dates_select = """
SELECT * FROM SLRMSCD WHERE SLRMSCD_TERM_CODE = $%$TERM$%$ AND SLRMSCD_MSCD_CODE = $%$ASSIGN_CODE$%$
"""
예제 #2
0
#!/usr/bin/python

import sch_client
import json
import pyodbc
import os


__location__ = os.path.realpath(os.path.join(os.getcwd(), os.path.dirname(__file__)))
sch_client.init_logging(__location__, 'sync_pull')
sch_client.printme('------ Begin sync_pull ------')
config = json.load(open(os.path.join(__location__, 'config.json')))
sql = open(os.path.join(__location__, config['pull_sql'])).read()
columns = json.load(open(os.path.join(__location__, config['pull_map'])))
api = sch_client.API(config['uri'], config['key'], config['secret'])

dbms = config['dbms'] if 'dbms' in config else 'odbc'
if dbms == 'oracle':
    import cx_Oracle
    connection = cx_Oracle.connect(config['db_connection'])
else:
    connection = pyodbc.connect(config['db_connection'])


def execute_pull(api, conn, query, params, columns, batch_size=10):
    cursor = conn.cursor()

    if dbms == 'oracle':
        query, query_params = sch_client.prepare_query(query, params, ':0')
        cursor.execute(query, query_params)
    else:
예제 #3
0
#!/usr/bin/python

import sch_client
import json
import pyodbc
import os
from collections import defaultdict
from copy import copy

__location__ = os.path.realpath(os.path.join(os.getcwd(), os.path.dirname(__file__)))
sch_client.init_logging(__location__, 'sync_push_jenzabar')
sch_client.printme('------ Begin sync_push_jenzabar ------')
config = json.load(open(os.path.join(__location__, 'config.json')))
api = sch_client.API(config['uri'], config['key'], config['secret'])
connection = pyodbc.connect(config['db_connection'])
cursor = connection.cursor()
verbose = False

room_assign_update = """
UPDATE ROOM_ASSIGN
SET ID_NUM = $%$id$%$,
    ASSIGN_DTE = $%$assign_time$%$,
    JOB_TIME = GETDATE(),
    JOB_NAME = 'sch.import_residency',
    USER_NAME = 'SCH',
    ROOM_ASSIGN_STS = 'A',
    ROOM_TYPE = $%$ROOM_TYPE$%$
WHERE SESS_CDE = $%$SESS_CDE$%$
AND BLDG_LOC_CDE = $%$BLDG_LOC_CDE$%$
AND BLDG_CDE = $%$BLDG_CDE$%$
AND ROOM_CDE = $%$ROOM_CDE$%$
예제 #4
0
#!/usr/bin/python

import sch_client
import json
import pyodbc
import os

__location__ = os.path.realpath(os.path.join(os.getcwd(), os.path.dirname(__file__)))
sch_client.init_logging(__location__, 'sync_push_powercampus')
sch_client.printme('------ Begin sync_push_powercampus ------')
config = json.load(open(os.path.join(__location__, 'config.json')))
api = sch_client.API(config['uri'], config['key'], config['secret'])
connection = pyodbc.connect(config['db_connection'])
cursor = connection.cursor()
verbose = False

residency_select = """
SELECT RESIDENT_COMMUTER, DORM_CAMPUS, DORM_BUILDING, DORM_ROOM, DORM_PLAN
FROM Residency
WHERE PEOPLE_CODE_ID = $%$id$%$
AND ACADEMIC_YEAR = $%$ACADEMIC_YEAR$%$
AND ACADEMIC_TERM = $%$ACADEMIC_TERM$%$
AND ACADEMIC_SESSION = $%$ACADEMIC_SESSION$%$
"""

residency_update = """
UPDATE Residency
SET DORM_CAMPUS = $%$DORM_CAMPUS$%$,
 RESIDENT_COMMUTER = $%$RESIDENT_COMMUTER$%$,
 DORM_PLAN = $%$DORM_PLAN$%$,
 DORM_BUILDING = $%$DORM_BUILDING$%$,
예제 #5
0
#!/usr/bin/python3

import sch_client
import json
import os
import csv
import sys
import argparse

parser = argparse.ArgumentParser(description='Get config file and import file name from command line')

__location__ = os.path.realpath(os.path.join(os.getcwd(), os.path.dirname(__file__)))
sch_client.init_logging(__location__, 'csv_import')

# load config file from first argument if passed

parser.add_argument('-f', dest='csvname', nargs='?', default = None)
parser.add_argument('configFile', nargs='?', default=os.path.join(__location__, 'config.json'))

args = parser.parse_args()
configFile = args.configFile

config = json.load(open(configFile))
csvtemp = config['import_csv'] if 'import_csv' in config else 'import.csv'
csvname = args.csvname if args.csvname is not None else csvtemp

# initialize sch api library
identifier = config['identifier'] if 'identifier' in config else None
api = sch_client.API(config['uri'], config['key'], config['secret'], identifier)
encoding = config['input_encoding'] if 'input_encoding' in config else 'utf8'