Esempio n. 1
0
def get_product():
    try:
        conn = connection.establish_connection()
        cursor = conn.cursor()
        cursor.execute("SELECT * FROM Product")
        records = cursor.fetchall()
        return records
    except Exception as err:
        if conn:
            print("Connection Failed!", err)
    finally:
        # closing database connection.
        if conn:
            cursor.close()
            conn.close()
            print("Connection Closed!")
Esempio n. 2
0
def get_single_service(sid):
    try:
        conn = connection.establish_connection()
        cursor = conn.cursor()
        cursor.execute("SELECT * FROM Service WHERE serviceid = ?", (sid, ))
        record = cursor.fetchall()
        return record[0]
    except Exception as err:
        if conn:
            print("Connection Failed!", err)
    finally:
        # closing database connection.
        if conn:
            cursor.close()
            conn.close()
            print("Connection Closed!")
Esempio n. 3
0
def add_order(data):
    try:
        conn = connection.establish_connection()
        cursor = conn.cursor()
        cursor.execute("INSERT INTO Orderinfo (customerid, productid, serviceid, origindate, finalperiod, finalprice) VALUES (?, ?, ?, ?, ?, ?)", data)
        conn.commit()
        return True
    except Exception as err:
        if conn:
            print("Connection Failed!", err)
    finally:
        # closing database connection.
        if conn:
            cursor.close()
            conn.close()
            print("Connection Closed!")
Esempio n. 4
0
def get_order(custid):
    try:
        conn = connection.establish_connection()
        cursor = conn.cursor()
        cursor.execute("SELECT * FROM Orderinfo Where customerid = ?", (custid,))
        records = cursor.fetchall()
        return records
    except Exception as err:
        if conn:
            print("Connection Failed!", err)
    finally:
        # closing database connection.
        if conn:
            cursor.close()
            conn.close()
            print("Connection Closed!")
Esempio n. 5
0
def add_user(data):
    try:
        conn = connection.establish_connection()
        cursor = conn.cursor()
        cursor.execute("INSERT INTO Customer (username, password) VALUES (?, ?)", data)
        conn.commit()
        return True
    except Exception as err:
        if conn:
            print("Connection Failed!", err)
    finally:
        # closing database connection.
        if conn:
            cursor.close()
            conn.close()
            print("Connection Closed!")
Esempio n. 6
0
def update_support(usage, support_id):
    try:
        conn = connection.establish_connection()
        cursor = conn.cursor()
        cursor.execute("Update Support SET usage = ? where supportid = ? ", (
            usage,
            support_id,
        ))
        conn.commit()
        return True
    except Exception as err:
        if conn:
            print("Connection Failed!", err)
    finally:
        # closing database connection.
        if conn:
            cursor.close()
            conn.close()
            print("Connection Closed!")
Esempio n. 7
0
def read_service(pid, sid):
    try:
        conn = connection.establish_connection()
        cursor = conn.cursor()
        cursor.execute(
            "SELECT * FROM Support WHERE productid = ? AND serviceid = ?", (
                pid,
                sid,
            ))
        records = cursor.fetchall()
        return records
    except Exception as err:
        if conn:
            print("Connection Failed!", err)
    finally:
        # closing database connection.
        if conn:
            cursor.close()
            conn.close()
            print("Connection Closed!")