Exemple #1
0
    def delete_contact(cid):
        try:
            connection = DbUtil.get_connection()
            cursor = connection.cursor()
            cursor.execute("delete from contact where cid = %s ", cid)
            connection.commit()

        except pymysql.DatabaseError as error:
            print("While deleting data ...")
            print('Exception number: {}, value {!r}'.format(
                error.args[0], error))
        finally:
            DbUtil.close_connection(connection)
            DbUtil.close_cursor(cursor)
 def update_patient(self, contact):
     try:
         conn = DbUtil.get_connection()
         cursor = conn.cursor()
         cursor.execute(
             "update pms set name=%s,phone=%s,payment=%s,prob=%s,ward=%s,doc=%s  where pid = %s",
             contact)
         conn.commit()
     except pymysql.DatabaseError as error:
         print("While updating ... ")
         print('Exception number: {}, value {!r}'.format(
             error.args[0], error))
     finally:
         DbUtil.close_connection(conn)
         DbUtil.close_cursor(cursor)
    def user_delete(user):
        try:
            connection = DbUtil.get_connection()
            cursor = connection.cursor()
            print("User is going to delete with id ", user.i_d)
            cursor.execute("delete from login where id = %s ", str(user.i_d))
            connection.commit()

        except pymysql.DatabaseError as error:
            print("While deleting data ...")
            print('Exception number: {}, value {!r}'.format(
                error.args[0], error))
        finally:
            DbUtil.close_connection(connection)
            DbUtil.close_cursor(cursor)
    def med_module(self, med):
        try:
            connection = DbUtil.get_connection()
            with connection.cursor() as cursor:
                cursor.execute(
                    "update pms set med = %s ,quant = %s where pid = %s", med)
            connection.commit()

        except pymysql.MySQLError as error:
            print("While inserting Data ...")
            print('Exception number: {}, value {!r}'.format(
                error.args[0], error))
        finally:
            DbUtil.close_connection(connection)
            DbUtil.close_cursor(cursor)
 def get_all_logins(self):
     try:
         connection = DbUtil.get_connection()
         with connection.cursor() as cursor:
             cursor.execute("select id,name,username,password from login")
             rows = cursor.fetchall()
             login = self.get_list_data5(rows)
             return login
     except Exception as error:
         print("While retrieving data ... ")
         print('Exception number: {}, value {!r}'.format(
             error.args[0], error))
     finally:
         if connection:
             DbUtil.close_connection(connection)
             DbUtil.close_cursor(cursor)
Exemple #6
0
 def queryCateListByIdList(self, cateIdList):
     if not cateIdList:
         return None
     format_str = ','.join(['%s'] * len(cateIdList))
     query = 'SELECT * FROM ffstore_category WHERE cate_id IN (%s)' % format_str, tuple(
         cateIdList)
     return DbUtil.query(query)
Exemple #7
0
 def save(self, adbBean):
     if not adbBean or not isinstance(adbBean, AdbBean):
         return
     insert = 'insert into adb_cmds (adb_cmd_name, adb_cmd, adb_cmd_desc) ' \
              'values("%s", "%s", "%s")' \
              % (adbBean.adb_cmd_name, adbBean.adb_cmd, adbBean.adb_cmd_desc)
     return DbUtil.insert(insert)
Exemple #8
0
 def saveToDb(self, dbBrand):
     if isinstance(dbBrand, DbBrand):
         insert = 'insert into ffstore_brand (brand_id, brand_name, brand_logo) ' \
                  'values("%s", "%s", "%s") ' \
                  % (dbBrand.brand_id, dbBrand.brand_name, dbBrand.brand_logo)
         return DbUtil.insert(insert)
     return False
    def doc_module(self, new_doc):
        try:
            connection = DbUtil.get_connection()
            with connection.cursor() as cursor:
                cursor.execute(
                    "insert into doc(name,dept,availabity) values(%s,%s,%s)",
                    (new_doc.name, new_doc.dept, new_doc.availabity))
            connection.commit()

        except pymysql.MySQLError as error:
            print("While inserting Data ...")
            print('Exception number: {}, value {!r}'.format(
                error.args[0], error))
        finally:
            DbUtil.close_connection(connection)
            DbUtil.close_cursor(cursor)
Exemple #10
0
 def updateLoginTime(self, admin_tel, login_time):
     current_time = DateUtil().getCurrentTimeStamp()
     if not login_time or login_time > current_time:
         return False
     update = 'update ffstore_admin set login_time = "%s" where admin_tel = "%s"' % (
         login_time, admin_tel)
     return DbUtil.update(update)
Exemple #11
0
 def updateCurrentPrice(self, goods_id, current_price):
     if not goods_id:
         return False
     currentPrice = 0 if current_price < 0 else current_price
     update = 'update ffstore_goods set current_price = "%s" where goods_id = "%s"' % (
         currentPrice, goods_id)
     return DbUtil.update(update)
Exemple #12
0
 def updateMarketPrice(self, goods_id, market_price):
     if not goods_id:
         return False
     marketPrice = 0 if market_price < 0 else market_price
     update = 'update ffstore_goods set market_price = "%s" where goods_id = "%s"' % (
         marketPrice, goods_id)
     return DbUtil.update(update)
Exemple #13
0
 def updateStockNum(self, goods_id, stock_num):
     if not goods_id:
         return False
     stock_num = 0 if stock_num < 0 else stock_num
     update = 'update ffstore_goods set stock_num = "%s" where goods_id = "%s"' % (
         stock_num, goods_id)
     return DbUtil.update(update)
Exemple #14
0
 def updateSaleCount(self, goods_id, sale_count):
     if not goods_id:
         return False
     saleCount = 0 if sale_count < 0 else sale_count
     update = 'update ffstore_goods set sale_count = "%s" where goods_id = "%s"' % (
         saleCount, goods_id)
     return DbUtil.update(update)
Exemple #15
0
 def queryGoodsListByGoodsIdList(self, goods_id_list):
     if not goods_id_list:
         return None
     format_str = ','.join(['%s'] * len(goods_id_list))
     query = 'SELECT * FROM ffstore_goods WHERE goods_id IN (%s)' % format_str, tuple(
         goods_id_list)
     return DbUtil.query(query)
Exemple #16
0
 def save(self, tipsBean):
     if not tipsBean or not isinstance(tipsBean, TipsBean):
         return
     insert = 'insert into tips_today (tips_type, tips_desc) ' \
              'values("%s", "%s")' \
              % (tipsBean.tips_type, tipsBean.tips_desc)
     return DbUtil.insert(insert)
 def get_all_docs(self):
     try:
         connection = DbUtil.get_connection()
         with connection.cursor() as cursor:
             cursor.execute("select name,dept,availabity from doc")
             rows = cursor.fetchall()
             doctor = self.get_list_data3(rows)
             return doctor
     except Exception as error:
         print("While retrieving data ... ")
         print('Exception number: {}, value {!r}'.format(
             error.args[0], error))
     finally:
         if connection:
             DbUtil.close_connection(connection)
             DbUtil.close_cursor(cursor)
Exemple #18
0
    def user_update(self, contact):
        try:
            conn = DbUtil.get_connection()
            cursor = conn.cursor()
            cursor.execute(
                "update new_student set name=%s,semister=%s,dept=%s,contact=%s where usn = %s",
                contact)
            conn.commit()

        except pymysql.DatabaseError as error:
            print("While updating ... ")
            print('Exception number: {}, value {!r}'.format(
                error.args[0], error))
        finally:
            DbUtil.close_connection(conn)
            DbUtil.close_cursor(cursor)
 def get_all_meds(self):
     try:
         connection = DbUtil.get_connection()
         with connection.cursor() as cursor:
             cursor.execute("select pid,name,doc,med,quant from pms")
             rows = cursor.fetchall()
             med_p = self.get_list_data4(rows)
             return med_p
     except Exception as error:
         print("While retrieving data ... ")
         print('Exception number: {}, value {!r}'.format(
             error.args[0], error))
     finally:
         if connection:
             DbUtil.close_connection(connection)
             DbUtil.close_cursor(cursor)
Exemple #20
0
 def queryCateAttrList(self, cateIdList):
     if cateIdList is None:
         return None
     format_str = ','.join(['%s'] * len(cateIdList))
     query = 'SELECT * FROM ffstore_attr WHERE cate_id IN (%s)' % format_str, tuple(
         cateIdList)
     return DbUtil.query(query)
    def login_module(self, new_log):
        try:
            connection = DbUtil.get_connection()
            with connection.cursor() as cursor:
                cursor.execute(
                    "insert into login(id,name,username,password) values(%s,%s,%s,%s)",
                    (new_log.i_d, new_log.name, new_log.un, new_log.pwd))
            connection.commit()

        except pymysql.MySQLError as error:
            print("While inserting Data ...")
            print('Exception number: {}, value {!r}'.format(
                error.args[0], error))
        finally:
            DbUtil.close_connection(connection)
            DbUtil.close_cursor(cursor)
Exemple #22
0
 def updateStatus(self, orderInfo):
     if isinstance(orderInfo, DbOrder):
         currentTime = self.dateUtil.getCurrentTime()
         update = 'update ffstore_order set order_status = "%s", order_update_time = "%s" where order_id = "%s" ' \
                  % (orderInfo.order_status, currentTime, orderInfo.order_id)
         return DbUtil.update(update)
     return False
Exemple #23
0
 def save(self, orderBean):
     if not orderBean or not isinstance(orderBean, WorkOrderBean):
         return
     insert = 'insert into work_oder (order_num, order_title, oder_reason, deal_time) ' \
              'values("%s", "%s", "%s", "%s")' \
              % (orderBean.order_num, orderBean.order_title, orderBean.order_reason, orderBean.deal_time)
     return DbUtil.insert(insert)
Exemple #24
0
 def updateTelToDb(self, userInfo):
     if isinstance(userInfo, DbUser):
         update = 'update ffstore_user set user_tel = "%s" where user_id = "%s" ' \
                  % (userInfo.user_tel, userInfo.user_id)
         print 'update user tel and address to db'
         return DbUtil.update(update)
     return False
Exemple #25
0
 def querySortGoodsByCateId(self,
                            cate_id,
                            goods_size,
                            page_num=1,
                            page_size=10,
                            sort=GoodsSort.SORT_COMMON):
     if not cate_id:
         return None
     start = (page_num - 1) * page_size
     if sort == GoodsSort.SORT_PRICE_DOWN:
         sort_str = ', current_price desc'
     elif sort == GoodsSort.SORT_PRICE_UP:
         sort_str = ', current_price asc'
     elif sort == GoodsSort.SORT_SALE_COUNT:
         sort_str = ', sale_count desc'
     else:
         sort_str = ', desc'
     if not goods_size:
         query = 'select * from ffstore_goods where cate_id = "%s" order by _id ' \
                 + sort_str + ' limit %s, %s;' % (cate_id, start, page_size)
     else:
         # join ffstore_attr table
         query = 'select * from ffstore_goods left join ffstore_attr on ffstore_goods.goods_id = ' \
                 'ffstore_attr.goods_id where ffstore_goods.cate_id = "%s" and ' \
                 'ffstore_attr.attr_size = "%s" order by _id ' + sort_str + ' limit %s, %s;' \
                 % (cate_id, goods_size, start, page_size)
     return DbUtil.query(query)
Exemple #26
0
 def updateCodeToDb(self, old_code, new_code):
     if not old_code or not new_code:
         return False
     update = 'update ffstore_category set cate_code = "%s" where cate_code = "%s" ' \
              % (new_code, old_code)
     print 'update category code to db'
     return DbUtil.update(update)
Exemple #27
0
 def updateShowTypeToDb(self, cate):
     if isinstance(cate, DbCategory):
         update = 'update ffstore_category set cate_show_type = "%s" where cate_code = "%s" ' \
                  % (cate.cate_show_type, cate.cate_code)
         print 'update category cate show type to db'
         return DbUtil.update(update)
     return False
Exemple #28
0
 def updateNameToDb(self, cate):
     if isinstance(cate, DbCategory):
         update = 'update ffstore_category set cate_name = "%s" where cate_code = "%s" ' \
                  % (cate.cate_name, cate.cate_code)
         print 'update category name to db'
         return DbUtil.update(update)
     return False
Exemple #29
0
 def updateLogoToDb(self, cate):
     if isinstance(cate, DbCategory):
         update = 'update ffstore_category set cate_logo = "%s" where cate_code = "%s" ' \
                  % (cate.cate_logo, cate.cate_code)
         print 'update category logo to db'
         return DbUtil.update(update)
     return False
Exemple #30
0
 def saveToDb(self, cate):
     if isinstance(cate, DbCategory):
         insert = 'insert into ffstore_category (cate_id, cate_code, parent_code, cate_logo, cate_name, cate_show_type)' \
                  ' values("%s", "%s", "%s", "%s", "%s", "%s")' \
                  % (cate.cate_id, cate.cate_code, cate.parent_code, cate.cate_logo, cate.cate_name, cate.cate_show_type)
         print 'insert category to db.'
         return DbUtil.insert(insert)
     return False