示例#1
0
def insert(product_code,product_name,product_category,product_image,product_brand,product_price,product_detail):
	connection = connection_config.get_connection()
	print ("connect successful!!")
	try:
		with connection.cursor() as cursor:
			sql = "INSERT INTO product VALUES (%s,%s,%s,%s,%s,%s,%s);"       
			cursor.execute(sql,(product_code,product_name,product_category,product_image,product_brand,product_price,product_detail))
			connection.commit()
			print('insert')                 
	finally:     
		connection.close()
示例#2
0
def update(product_code,product_name,product_category,product_image,product_brand,product_price,product_detail,old_product_code):
	connection = connection_config.get_connection()
	print ("connect successful!!")
	try:
		with connection.cursor() as cursor:
			sql = "UPDATE product SET product_code = %s, product_name = %s, product_category = %s, product_image = %s, product_brand = %s, product_price = %s, product_detail = %s WHERE product_code = %s"       
			cursor.execute(sql,(product_code,product_name,product_category,product_image,product_brand,product_price,product_detail,old_product_code))
			connection.commit()
			print('update')                 
	finally:     
		connection.close()
def insert(bill_code,product_code,product_quantity,into_money):
	connection = connection_config.get_connection()
	print ("connect successful!!")
	try:
		with connection.cursor() as cursor:
			sql = "INSERT INTO bill_detail VALUES (%s,%s,%s,%s);"       
			cursor.execute(sql,(bill_code,product_code,product_quantity,into_money))
			connection.commit()
			print('insert')                 
	finally:     
		connection.close()
def update(bill_code,product_code,product_quantity,into_money,old_bill_code,old_product_code):
	connection = connection_config.get_connection()
	print ("connect successful!!")
	try:
		with connection.cursor() as cursor:
			sql = "UPDATE bill_detail SET bill_code = %s, product_code = %s, product_quantity = %s, into_money = %s WHERE bill_code = %s AND product_code = %s"       
			cursor.execute(sql,(bill_code,product_code,product_quantity,into_money,old_bill_code,old_product_code))
			connection.commit()
			print('update')                 
	finally:     
		connection.close()		
示例#5
0
def select_all():
    connection = connection_config.get_connection()
    print("connect successful!!")
    try:
        with connection.cursor() as cursor:
            sql = "SELECT * FROM product "
            row = cursor.execute(sql)
            print("select all")
    finally:
        connection.close()
    return [cursor.fetchall(), row]
示例#6
0
def delete(product_code):
    connection = connection_config.get_connection()
    print("connect successful!!")
    try:
        with connection.cursor() as cursor:
            sql = "DELETE FROM product where product_code = %s"
            cursor.execute(sql, (product_code))
            connection.commit()
            print('delete')
    finally:
        connection.close()
示例#7
0
def insert(product_code, inventory_number):
    connection = connection_config.get_connection()
    print("connect successful!!")
    try:
        with connection.cursor() as cursor:
            sql = "INSERT INTO warehouse VALUES (%s,%s);"
            cursor.execute(sql, (product_code, inventory_number))
            connection.commit()
            print('insert')
    finally:
        connection.close()
示例#8
0
def select(bill_code,product_code):
	connection = connection_config.get_connection()
	print ("connect successful!!")
	try:
		with connection.cursor() as cursor:
			sql = "SELECT * FROM bill_detail WHERE bill_code = %s AND product_code = %s"       
			row = cursor.execute(sql,(bill_code,product_code))
			print ("select")
	finally:      
		connection.close()
	return [cursor.fetchall(), row]
示例#9
0
def insert(customer_code,customer_name,customer_address,customer_phone,customer_sex,customer_DOB,customer_DOP):
	connection = connection_config.get_connection()
	print ("connect successful!!")
	try:
		with connection.cursor() as cursor:
			sql = "INSERT INTO customer VALUES (%s,%s,%s,%s,%s,%s,%s);"       
			cursor.execute(sql,(customer_code,customer_name,customer_address,customer_phone,customer_sex,customer_DOB,customer_DOP))
			connection.commit()
			print('insert')                 
	finally:     
		connection.close()
示例#10
0
def select(customer_code):
    connection = connection_config.get_connection()
    print("connect successful!!")
    try:
        with connection.cursor() as cursor:
            sql = "SELECT * FROM customer WHERE customer_code = %s"
            row = cursor.execute(sql, (customer_code))
            print("select")
    finally:
        connection.close()
    return [cursor.fetchall(), row]
示例#11
0
def select_all():
	connection = connection_config.get_connection()
	print ("connect successful!!")
	try:
		with connection.cursor() as cursor:
			sql = "SELECT * FROM product "       
			cursor.execute(sql)
			cursor_2 = cursor
			print ("select")
	finally:      
		connection.close()
	return cursor_2
示例#12
0
def update(product_code, inventory_number, old_product_code):
    connection = connection_config.get_connection()
    print("connect successful!!")
    try:
        with connection.cursor() as cursor:
            sql = "UPDATE warehouse SET product_code = %s, inventory_number = %s WHERE product_code = %s"
            cursor.execute(sql,
                           (product_code, inventory_number, old_product_code))
            connection.commit()
            print('update')
    finally:
        connection.close()
示例#13
0
def insert(employee_code, employee_name, employee_sex, employee_address,
           employee_phone, employee_DOB, employee_FWD, employee_salary):
    connection = connection_config.get_connection()
    print("connect successful!!")
    try:
        with connection.cursor() as cursor:
            sql = "INSERT INTO employee VALUES (%s,%s,%s,%s,%s,%s,%s,%s);"
            cursor.execute(
                sql,
                (employee_code, employee_name, employee_sex, employee_address,
                 employee_phone, employee_DOB, employee_FWD, employee_salary))
            connection.commit()
            print('insert')
    finally:
        connection.close()
示例#14
0
def update(bill_code, employee_code, bill_date, bill_time, customer_code,
           total_cost, discount, bill_cost, bill_note, old_bill_code):
    connection = connection_config.get_connection()
    print("connect successful!!")
    try:
        with connection.cursor() as cursor:
            sql = "UPDATE bill SET bill_code = %s, employee_code = %s, bill_date = %s, bill_time = %s, customer_code = %s, total_cost = %s, discount = %s, bill_cost = %s, bill_note = %s WHERE bill_code = %s"
            cursor.execute(
                sql,
                (bill_code, employee_code, bill_date, bill_time, customer_code,
                 total_cost, discount, bill_cost, bill_note, old_bill_code))
            connection.commit()
            print('update')
    finally:
        connection.close()
示例#15
0
def insert(bill_code, employee_code, bill_date, bill_time, customer_code,
           total_cost, discount, bill_cost, bill_note):
    connection = connection_config.get_connection()
    print("connect successful!!")
    try:
        with connection.cursor() as cursor:
            sql = "INSERT INTO bill VALUES (%s,%s,%s,%s,%s,%s,%s,%s,%s);"
            cursor.execute(
                sql,
                (bill_code, employee_code, bill_date, bill_time, customer_code,
                 total_cost, discount, bill_cost, bill_note))
            connection.commit()
            print('insert')
    finally:
        connection.close()
示例#16
0
def update(customer_code, customer_name, customer_address, customer_phone,
           customer_sex, customer_DOB, customer_DOP, old_customer_code):
    connection = connection_config.get_connection()
    print("connect successful!!")
    try:
        with connection.cursor() as cursor:
            sql = "UPDATE customer SET customer_code = %s, customer_name = %s, customer_address = %s, customer_phone = %s, customer_sex = %s, customer_DOB = %s, customer_DOP = %s WHERE customer_code = %s"
            cursor.execute(sql,
                           (customer_code, customer_name, customer_address,
                            customer_phone, customer_sex, customer_DOB,
                            customer_DOP, old_customer_code))
            connection.commit()
            print('update')
    finally:
        connection.close()