def get_profile_by_id(id): cur = dblayer.run("SELECT * FROM Profiles WHERE id=?", (id,)) rows = dblayer.getRows(cur) if len(rows) == 0: return None return {'localSource': rows[0]['localSource'], 'localSourceTitle': rows[0]['localSourceTitle'], 'remoteAccountId': rows[0]['remoteAccountId'], 'remoteSource': rows[0]['remoteSource'], 'remoteSourceTitle': rows[0]['remoteSourceTitle'], 'enabled': rows[0]['enabled'], 'direction': rows[0]['direction'], 'lastUpdate': rows[0]['lastUpdate'], 'id': rows[0]['id'], 'lastLocalUpdate': rows[0]['lastLocalUpdate']}
def get_registered_accounts(): cur = dblayer.run("SELECT id, username FROM GoogleAccounts") rows = dblayer.getRows(cur) accts = [] for i in rows: accts.append([i['id'], i['username']]) return accts
def get_all(): cur = dblayer.run("SELECT * FROM Profiles") rows = dblayer.getRows(cur) profiles = [] for i in rows: profiles.append([i['id'], i['type'], i['localSource'], i['localSourceTitle'], i['remoteSource'], i['remoteSourceTitle'], i['enabled'], i['direction'], i['lastUpdate'], i['lastLocalUpdate']]) return profiles
def get_all(): cur = dblayer.run("SELECT * FROM Profiles") rows = dblayer.getRows(cur) profiles = [] for i in rows: profiles.append([ i['id'], i['type'], i['localSource'], i['localSourceTitle'], i['remoteSource'], i['remoteSourceTitle'], i['enabled'], i['direction'], i['lastUpdate'], i['lastLocalUpdate'] ]) return profiles
def get(self): try: parser = reqparse.RequestParser() addAuthArgs(parser) parser.add_argument('tableName', type=str) args = parser.parse_args() if authenticate(args)['status'] == 100: return {'error': 'Authentication Failed'} _tableName = args['tableName'] return getRows(_tableName, '*') except Exception as e: return {'error': str(e)}
def get_profile_by_id(id): cur = dblayer.run("SELECT * FROM Profiles WHERE id=?", (id, )) rows = dblayer.getRows(cur) if len(rows) == 0: return None return { 'localSource': rows[0]['localSource'], 'localSourceTitle': rows[0]['localSourceTitle'], 'remoteAccountId': rows[0]['remoteAccountId'], 'remoteSource': rows[0]['remoteSource'], 'remoteSourceTitle': rows[0]['remoteSourceTitle'], 'enabled': rows[0]['enabled'], 'direction': rows[0]['direction'], 'lastUpdate': rows[0]['lastUpdate'], 'id': rows[0]['id'], 'lastLocalUpdate': rows[0]['lastLocalUpdate'] }
def get_account_by_id(id): cur = dblayer.run("SELECT username, password FROM GoogleAccounts "\ "WHERE id = ?", (id,)) row = dblayer.getRows(cur)[0] return (row['username'], row['password'], id)
def get_titles_by_id(id): cur = dblayer.run("SELECT localSourceTitle, remoteSourceTitle FROM "\ "Profiles WHERE id=?", (id,)) rows = dblayer.getRows(cur) return (rows[0]['localSourceTitle'], rows[0]['remoteSourceTitle'])