def add_facebook_user(reflink, facebookId): conn = dbConnection.connect_to_database() if conn.execute("INSERT INTO facebook_user (LICZBA_OSOB_Z_POLECENIA, REFLINK, FACEBOOK_ID) VALUE (0, ?, ?)", (reflink, facebookId)): dbConnection.commit(conn) return True else: dbConnection.rollback(conn) return False
def remove_user_dojo_relation(userId, dojoId): conn = dbConnection.connect_to_database() if conn.execute("DELETE FROM dojo_user WHERE USER_ID = ? AND DOJO_ID = ?", userId, dojoId): dbConnection.commit(conn) return True else: dbConnection.rollback(conn) return False
def remove_facebook_user(facebookId): conn = dbConnection.connect_to_database() if conn.execute("DELETE FROM facebook_user where FACEBOOK_ID = ?", (facebookId,)): dbConnection.commit(conn) return True else: dbConnection.rollback(conn) return False
def remove_organizacja(organizacjaId): conn = dbConnection.connect_to_database() if conn.execute("DELETE FROM organizacje WHERE ID = ?", (organizacjaId,)): dbConnection.commit(conn) return True else: dbConnection.rollback(conn) return False
def delete_users_umiejetnosci(userId): conn = dbConnection.connect_to_database() if conn.execute("DELETE FROM user_umiejetnosc where USER_ID = ?", userId): dbConnection.commit(conn) return True else: dbConnection.rollback(conn) return False
def add_zdjecie(hash, organizacjaId): conn = dbConnection.connect_to_database() if conn.execute("INSERT INTO ZDJECIE (B64_HASH, ORGANIZACJA_ID) VALUE (?, ?)", (hash, organizacjaId)): dbConnection.commit(conn) return True else: dbConnection.rollback(conn) return False
def remove_umiejetnosc(umiejetnoscId): conn = dbConnection.connect_to_database() if conn.execute("DELETE FROM sl_umiejetnosci WHERE ID = ?", umiejetnoscId): dbConnection.commit(conn) return True else: dbConnection.rollback(conn) return False
def remove_zdjecie_by_organizacja_id(organizacjaId): conn = dbConnection.connect_to_database() if conn.execute("DELETE FROM ORGAN_ZDJECIE WHERE ORGANIZACJA_ID = ?", (organizacjaId,)): dbConnection.commit(conn) return True else: dbConnection.rollback(conn) return False
def set_organizacja_potwierdzona(organizacjaId): conn = dbConnection.connect_to_database() if conn.execute("UPDATE organizacje SET CZY_POTWIERDZONY = ?", 1): dbConnection.commit(conn) return True else: dbConnection.rollback(conn) return False
def add_organizacja(nazwa, email, nrKrs): conn = dbConnection.connect_to_database() if conn.execute("INSERT INTO organizacje (NAZWA, EMAIL, NR_KRS, CZY_POTWIERDZONY) VALUE (?, ?, ?, 0)", (nazwa, email, nrKrs)): dbConnection.commit(conn) return True else: dbConnection.rollback(conn) return False
def add_umiejetnosc(umiejetnoscNazwa): conn = dbConnection.connect_to_database() if conn.execute("INSERT INTO sl_umiejetnosci (NAZWA) VALUE (?)", umiejetnoscNazwa): dbConnection.commit(conn) return True else: dbConnection.rollback(conn) return False
def add_organizacja_zdjecie_relation(organizacjaId, zdjecieId): conn = dbConnection.connect_to_database() params = (organizacjaId, zdjecieId) if conn.execute("INSERT INTO ORGAN_ZDJECIE (ORGANIZACJA_ID, ZDJECIE_ID) VALUE (?, ?)", params): dbConnection.commit(conn) return True else: dbConnection.rollback(conn) return False
def set_wiadomosc_czy_przeczytany(wiadomoscId, czyPrzeczytany): conn = dbConnection.connect_to_database() params = (czyPrzeczytany, wiadomoscId) if conn.execute("UPDATE wiadomosc SET CZY_PRZECZYTANY = ? WHERE ID = ?", params): dbConnection.commit(conn) return True else: dbConnection.rollback(conn) return False
def find_user_id_by_login(login): conn = dbConnection.connect_to_database() id = conn.cursor().execute("SELECT id FROM user where LOGIN = ? AND PASSWORD = ?", (login,)).fetchone()[0] if id is not None: dbConnection.commit(conn) return id else: dbConnection.rollback(conn) return None
def delete_user(login, password): conn = dbConnection.connect_to_database() if does_user_exist(login, password): params = (login, password) if conn.execute("DELETE FROM user WHERE LOGIN = ? AND PASSWORD = ?", params): dbConnection.commit(conn) return True else: dbConnection.rollback(conn) return False
def add_wiadomosc(nadawcaId, odbiorcaId, tresc, temat): conn = dbConnection.connect_to_database() czyPrzeczytany = 0 if conn.execute("INSERT INTO wiadomosc (NADAWCA_ID, ODBIORCA_ID, TEMAT, TRESC, CZY_PRZECZYTANY, DATA_WYSLANIA) " "VALUES (?, ?, ?, ?, ?, ?)", nadawcaId, odbiorcaId, temat, tresc, czyPrzeczytany, datetime.datetime.now().strftime('%Y/%m/%d %H:%M:%S')): dbConnection.commit(conn) return True else: dbConnection.rollback(conn) return False
def add_user(login, email, password, skillsList, czyZdalny, czyPedagog, czyUspiony, miejscowosc): conn = dbConnection.connect_to_database() params = (email, password, login, miejscowosc[0], czyUspiony, czyZdalny, czyPedagog) if conn.execute("INSERT INTO user (EMAIL, PASSWORD, LOGIN, LOKALIZACJA, CZY_USPIONY, CZY_ZDALNY, CZY_PEDAGOG) " "VALUES (?, ?, ?, ?, ?, ?, ?)", params): dbConnection.commit(conn) userUmiejetnoscDAO.add_relations(login, skillsList) return True else: dbConnection.rollback(conn) return False
def add_user_dojo_relation(userLogin, miejscowosc): conn = dbConnection.connect_to_database() userId = conn.cursor().execute("SELECT ID FROM USER WHERE LOGIN = ?", (userLogin,)).fetchone()[0] dojoId = conn.cursor().execute("SELECT ID FROM dojo WHERE LOKALIZACJA = ?", (miejscowosc[0],)).fetchone()[0] params = (dojoId, userId) if conn.execute("INSERT INTO dojo_user VALUES (?, ?)", params): ilosc_mentorow = conn.execute("SELECT IL_MENTOROW FROM dojo WHERE ID = ?", dojoId) ilosc_mentorow += 1 parameters = (ilosc_mentorow, dojoId) if conn.execute("UPDATE dojo SET IL_MENTOROW = ? WHERE ID = ?", parameters): dbConnection.commit(conn) return True else: dbConnection.rollback(conn) return False