コード例 #1
0
ファイル: update.py プロジェクト: joshkelly/fuel
def main():
    global conn, cur
    # open/create db file
    conn = dbi.init()
    conn.row_factory = sqlite3.Row
    cur = conn.cursor()

    update_vehicles()
    update_fuel()
    update_service()

    dbi.close()
コード例 #2
0
ファイル: functions.py プロジェクト: joshkelly/fuel
def load():
    '''
    Load data from DB.
    Establish connection and get cursor.
    '''
    global conn, cur, fuel, vehicles, service
    if conn == None:
        conn = dbi.init()
        conn.row_factory = sqlite3.Row
        cur = conn.cursor()

    # get data, copy to editable dictionary, inform user of record count
    cur.execute('select * from fuel')
    fuel = [dict(row) for row in cur]
    print('Loaded {} fuel records.'.format(len(fuel)))
    
    cur.execute('select * from vehicles')
    vehicles = [dict(row) for row in cur]
    print('Loaded {} vehicles.'.format(len(vehicles)))

    cur.execute('select * from service')
    service = [dict(row) for row in cur]
    print('Loaded {} service records.'.format(len(service)))
コード例 #3
0
		info += 'paylaod: ' + json.dumps(pl,  indent=4, sort_keys=False, ensure_ascii=False) + '\n'
		info +=	"Respnose:" + json.dumps(response, indent=4, sort_keys=False, ensure_ascii=False) + '\n'
		print(info)
	else:
		response = {"status":sts['OSA_STATUS_ENOENT'], "payload":{}}

	return json.dumps(response)

@app.route('/', methods = ['GET', 'POST'])
def api_root():
	return 'hello python'
    
# main
##########################################################################
if __name__ == "__main__":
	print('[Api Info]:')
	print_array(urls)
	
	print('[Init DB ' +  dpath + ']:')
	dbi.init(dpath)

	print('[Run Server]:')
	app.run(host, port, dflg)

	print("[Deinit DB]:")
	dbi.deinit()

	print('[Exit]')