当前位置: 首页>>代码示例>>Python>>正文


Python DBUtil.cursor方法代码示例

本文整理汇总了Python中DBUtil.cursor方法的典型用法代码示例。如果您正苦于以下问题:Python DBUtil.cursor方法的具体用法?Python DBUtil.cursor怎么用?Python DBUtil.cursor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DBUtil的用法示例。


在下文中一共展示了DBUtil.cursor方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: import DBUtil [as 别名]
# 或者: from DBUtil import cursor [as 别名]
class OrderDaoImpl:
	def __init__(self):
		self.conn = DBUtil().openConnection()

	# save table info, return order_id
	def saveOrder(self, order):

		with self.conn:
			cur = self.conn.cursor()

			sql = " insert into OrderTbl(orderTime,userId,tableId,personNum)values(%s,%s,%s,%s) "
			# set arg
			value = [ order.getOrderTime(),
					order.getUserId(),
					order.getTableId(),
					order.getPersonNum() ]
			# execute
			cur.execute(sql, value);  

			# return order_id
			sql2 = " select max(id) as id from OrderTbl "
			cur.execute(sql2) 

			row = cur.fetchone()
			return row[0]
	
	#save order list
	def saveOrderDetail(self, od):

		with self.conn:
			cur = self.conn.cursor()
			sql = " insert into OrderDetailTbl(orderId,menuId,num,remark)values(%s,%s,%s,%s) "

			value = [ od.getOrderId(),
					od.getMenuId(),
					od.getNum(),
					od.getRemark() ]
			# execute
			cur.execute(sql, value);  
	
	# using: update table status
	def updateTableStatus(self, table_id):

		with self.conn:
			cur = self.conn.cursor()

			sql = " update TableTbl set flag=1 where id = %s "
			cur.execute(sql, table_id)  
		
	
	# empty: update table status
	def updateTableStatus2(self, order_id): 

		 with self.conn:
			cur = self.conn.cursor()

			sql = " update TableTbl set flag = 0 where id = " +\
							" ( select tableId from OrderTbl where id = %s) "
			cur.execute(sql, order_id)  
开发者ID:onionisi,项目名称:judy_server,代码行数:61,代码来源:OrderDaoImpl.py

示例2: __init__

# 需要导入模块: import DBUtil [as 别名]
# 或者: from DBUtil import cursor [as 别名]
class CheckTableDaoImpl:

	def __init__(self):
		self.conn = DBUtil().openConnection()

	# 获得餐桌列表
	def getTableList(self):
		# 查询SQL语句
		sql =" select num,flag from TableTbl"
		with self.conn:
			cur = self.conn.cursor()

			cur.execute(sql)  

			# 获得预定义语句
			rows = cur.fetchall()
			result = []
			for row in rows:
				num = row[0]
				flag = row[1]

				ct = CheckTable()
				ct.setFlag(flag)
				ct.setNum(num)

				result.append(ct)
			
			return result
		return None
开发者ID:onionisi,项目名称:judy_server,代码行数:31,代码来源:CheckTableDaoImpl.py

示例3: __init__

# 需要导入模块: import DBUtil [as 别名]
# 或者: from DBUtil import cursor [as 别名]
class UserDaoImpl:
	
	def __init__(self):
		self.conn = DBUtil().openConnection()

	def login(self, account, password):
		# 查询SQL语句
		sql = " select id,account,password,name,permission,remark "+\
						" from UserTbl "+\
						" where account=%s and password=%s "
		with self.conn:
			cur = self.conn.cursor()

			values = [ account, password ]
			# 执行查询
			cur.execute(sql, values)  

			row = cur.fetchone()

			Id = row[0]
			name = row[3]
			permission = row[4]
			remark = row[5]
			# 封装用户信息
			u = User()
			
			u.setId(Id)
			u.setAccount(account)
			u.setPassword(password)
			u.setName(name)
			u.setPermission(permission)
			u.setRemark(remark)
			
			return u
		return None
开发者ID:onionisi,项目名称:judy_server,代码行数:37,代码来源:UserDaoImpl.py

示例4: __init__

# 需要导入模块: import DBUtil [as 别名]
# 或者: from DBUtil import cursor [as 别名]
class UnionTableDaoImpl:
	
	def __init__(self):
		self.conn = DBUtil().openConnection()

	def getTableList(self):
		# 查询SQL语句
		sql =" select id,num from TableTbl where flag = 1 "

		with self.conn:
			cur = self.conn.cursor()
			cur.execute(sql)  

			# 判断订单详细
			result = []
			rows = cur.fetchall()
			for row in rows:
				# 获得菜单信息
				Id = row[0]
				num = row[1]
				
				ut = UnionTable()
				ut.setId(Id)
				ut.setNum(num)
				
				result.append(ut)
			
			return result
		return None
	
	def updateStatus(self, tableId1, tableId2):
		with self.conn:
			cur = self.conn.cursor()

			prepare = "new_proc"
			values = [ tableId1, tableId2 ]

			cur.callproc(prepare, values)
开发者ID:onionisi,项目名称:judy_server,代码行数:40,代码来源:UnionTableDaoImpl.py

示例5: __init__

# 需要导入模块: import DBUtil [as 别名]
# 或者: from DBUtil import cursor [as 别名]
class UpdateDaoImpl:

	def __init__(self):
		self.conn = DBUtil().openConnection()

	# 获得菜单列表
	def getMenuList(self):
		# 查询SQL语句
		sql =" select id,type,price,name,pic,remark from MenuTbl "

		with self.conn:
			cur = self.conn.cursor()

			# 执行查询
			cur.execute(sql)  
			# 判断订单详细
			rows = cur.fetchall()
			result = []
			for row in rows:
				# 获得菜单信息
				Id     = row[0]
				typeId = row[1]
				price  = row[2]
				name   = row[3]
				pic    = row[4]
				remark = row[5]
				
				m = Menu()
				m.setId(Id)
				m.setName(name)
				m.setPic(pic)
				m.setPrice(price)
				m.setRemark(remark)
				m.setTypeId(typeId)
				
				result.append(m)
			
			return result
		return None
	
	# 获得餐桌列表
	def getTableList(self):
		# 查询SQL语句
		sql =" select id,num,description from TableTbl "

		with self.conn:
			cur = self.conn.cursor()

			# 执行查询
			cur.execute(sql)  
			# 判断订单详细
			rows = cur.fetchall()
			result = []
			for row in rows:
				# 获得菜单信息
				Id   = row[0]
				num  = row[1]
				desc = row[2]
				
				t = Table()
				t.setId(Id)
				t.setNum(num)
				t.setDesc(desc)
				
				result.append(t)
			
			return result

		return None
开发者ID:onionisi,项目名称:judy_server,代码行数:71,代码来源:UpdateDaoImpl.py


注:本文中的DBUtil.cursor方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。