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


Python Session.close方法代码示例

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


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

示例1: main_page

# 需要导入模块: from model import Session [as 别名]
# 或者: from model.Session import close [as 别名]
def main_page():
	s = Session()
	books = s.query(Book).all()
	authors = s.query(Author).all()
	s.close()

	return render_template('beta.html', books=books, authors=authors)
开发者ID:Azurin,项目名称:beta,代码行数:9,代码来源:controller.py

示例2: initialize_device

# 需要导入模块: from model import Session [as 别名]
# 或者: from model.Session import close [as 别名]
def initialize_device():
    """
    Set up the Device info into the database.
    By this time, the HardwareDefinition and SoftwareDefinition
    entries must be entered.
    """
    session = Session()

    hd = session.query(HardwareDefinition).one()
    sd = session.query(SoftwareDefinition).one()

    device = Device(id=hd.serial_number,
                    interior_sensor=hd.interior_sensor,
                    exterior_sensor=hd.exterior_sensor)

    device.hardware_version = hd.hardware_version
    device.software_version = sd.software_version
    device.database_service = True  # database always set to True
    device.device_service = sd.device_service
    device.grainbin_service = sd.grainbin_service
    session.add(device)

    # set grainbin info
    if sd.grainbin_service:
        grainbins = initialize_grainbin(device.id, hd.grainbin_reader_count)
        device.grainbin_count = len(grainbins)
        session.add_all(grainbins)

    session.commit()
    session.close()
    return
开发者ID:nstoik,项目名称:farm_device,代码行数:33,代码来源:db_manage.py

示例3: book_save

# 需要导入模块: from model import Session [as 别名]
# 或者: from model.Session import close [as 别名]
def book_save(_id):
	status, msg = True, ''
	b_name = request.args.get('name')

	s = Session()
	b = s.query(Book).filter_by(id=_id).first()

	del b.authors[:]

	for key, val in request.args.items():
		if key == 'name':
			continue
		a = s.query(Author).filter_by(id=key).first()
		b.authors.append(a)

	b.name = b_name
	try:
		s.commit()
	except IntegrityError:
		status = False
		msg = 'The book with name %s already exists' % b_name

	s.close()

	return json.dumps({'ok': status, 'msg': msg})
开发者ID:Azurin,项目名称:beta,代码行数:27,代码来源:controller.py

示例4: create_default_user

# 需要导入模块: from model import Session [as 别名]
# 或者: from model.Session import close [as 别名]
def create_default_user():
    session = Session()
    default_user = User('admin', 'password1234', '[email protected]')
    session.add(default_user)
    session.commit()
    session.close()
    return
开发者ID:nstoik,项目名称:farm_monitor,代码行数:9,代码来源:db_manage.py

示例5: draw_table

# 需要导入模块: from model import Session [as 别名]
# 或者: from model.Session import close [as 别名]
    def draw_table(self):
        s = Session()
        self.orders = s.query(Order).all()
        s.close()
        self.ui.orders_table.clear()
        self.ui.orders_table.setRowCount(1)
        self.ui.orders_table.setColumnCount(5)
        self.ui.orders_table.setHorizontalHeaderLabels([QString.fromUtf8('Номер'), QString.fromUtf8('Поломка'),
                                                        QString.fromUtf8('Дата приемки'), QString.fromUtf8('Клиент'),
                                                        QString.fromUtf8('Статус')])
        #self.ui.orders_table.resizeColumnsToContents()

        for order in self.orders:
            data = []
            data.append(str(order.id))
            data.append(QString.fromUtf8(order.device))
            data.append(str(order.get_ordered_date()))
            data.append(QString.fromUtf8(order.get_client().get_fio()))
            data.append(QString.fromUtf8(order.get_status(1).to_string()))
            for i in range(0,5):
                tableitem = QTableWidgetItem()
                tableitem.setText(data[i])
                tableitem.font = QFont("Arial", 10)
                tableitem.font.setBold(True)
                tableitem.textcolor = QColor("black")
                self.ui.orders_table.setItem(self.ui.orders_table.rowCount() - 1,i,tableitem)
            self.ui.orders_table.setRowCount(self.ui.orders_table.rowCount()+1)
        self.ui.orders_table.resizeColumnsToContents()
开发者ID:frolova,项目名称:sc,代码行数:30,代码来源:OrdersWidget.py

示例6: main_page

# 需要导入模块: from model import Session [as 别名]
# 或者: from model.Session import close [as 别名]
def main_page():
	s = Session()
	meals = s.query(Meal).all()
	products = s.query(Product).all()
	s.close()

	return render_template('beta.html', meals=meals, products=products)
开发者ID:Azurin,项目名称:kk,代码行数:9,代码来源:controller.py

示例7: do_command

# 需要导入模块: from model import Session [as 别名]
# 或者: from model.Session import close [as 别名]
def do_command (task_id) :
    try :
        task_res = get_task_by_id(task_id)
        if task_res["status"] != 0 :
            return {"status":-1 , "val":None}
        task = task_res["val"]["task"]
        group_id = script_group = task_res["val"]["script_group"].id
        server_group = task_res["val"]["server_group"]
        scripts = get_scripts_by_group_id(group_id)["val"]
        script_list = []
        for script in scripts :
            script_list.append(str(script.location))
        server_list = []
        for server in server_group.servers :
            server_list.append(server.dump())
        if script_list == [] or server_list == [] :
            return {"status":-1 , "val":None}
        task_to_do = {"scripts":script_list , "servers":server_list}
        success_array , key_code_list = upload_remotefile.do_task(task_to_do)
        session = Session()
        taskStatus = session.query(TaskStatus).filter(TaskStatus.task_id == task_id).first()
        if taskStatus == None :
            taskStatus = TaskStatus(task_id , json.dumps(success_array) , json.dumps(key_code_list))
            taskStatus_id = taskStatus.save_return_id(session)
        else :
            taskStatus.success_array = json.dumps(success_array)
            taskStatus.key_code_list = json.dumps(key_code_list)
            taskStatus_id = taskStatus.id
            taskStatus.save(session)
        session.close()
        return {"status":0 , "val":taskStatus_id}
    except Exception , msginfo :
        return {"status":-1 , "val":msginfo}
开发者ID:fikgol,项目名称:vulcan,代码行数:35,代码来源:helper.py

示例8: new_meal_save

# 需要导入模块: from model import Session [as 别名]
# 或者: from model.Session import close [as 别名]
def new_meal_save():
	status, msg = True, ''

	b_name = request.args.get('name')

	s = Session()
	b = Meal(b_name)

	for key, val in request.args.items():
		if key == 'name':
			continue
		a = s.query(Product).filter_by(id=key).first()
		b.products.append(a)

	s.add(b)

	try:
		s.commit()
	except IntegrityError:
		status = False
		msg = 'The meal with name %s already exists' % b_name

	s.close()

	return json.dumps({'ok': status, 'msg': msg})
开发者ID:Azurin,项目名称:kk,代码行数:27,代码来源:controller.py

示例9: login

# 需要导入模块: from model import Session [as 别名]
# 或者: from model.Session import close [as 别名]
 def login(self):
     s = Session()
     res = s.query(Staff).filter_by(login=unicode(self.ui.login.text()),
         passwd=unicode(self.ui.password.text())).all()
     if len(res):
         self.mv = MainWindow(res[0])
         self.mv.show()
         self.close()
     s.close()
开发者ID:frolova,项目名称:sc,代码行数:11,代码来源:LoginWindow.py

示例10: draw_client_combo

# 需要导入模块: from model import Session [as 别名]
# 或者: from model.Session import close [as 别名]
 def draw_client_combo(self):
     combo = self.ui.client
     s = Session()
     clients = s.query(Client).all()
     s.close()
     combo.clear()
     for cl in clients:
         combo.addItem('%i %s %s'%(cl.id, cl.surname, cl.name))
     #QObject.connect(self.ui.manufacter_combo, SIGNAL("currentIndexChanged(int)"), self.setManufacter)
     #self.setManufacter(0)
开发者ID:frolova,项目名称:sc,代码行数:12,代码来源:AddOrderWidget.py

示例11: remove_book

# 需要导入模块: from model import Session [as 别名]
# 或者: from model.Session import close [as 别名]
def remove_book():
	b_id   = request.args.get('id')

	s = Session()
	b = s.query(Book).filter_by(id=b_id).first()

	s.delete(b)
	s.commit()
	s.close()

	return json.dumps({'ok': True, 'msg': ''})
开发者ID:Azurin,项目名称:beta,代码行数:13,代码来源:controller.py

示例12: add_order

# 需要导入模块: from model import Session [as 别名]
# 或者: from model.Session import close [as 别名]
 def add_order(self):
     s = Session()
     ord = Order()
     ord.manager_id = self.parent.user.id
     ord.device =  unicode(self.ui.device.text())
     ord.description =  unicode(self.ui.description)
     ord.client_id = s.query(Client).filter_by(id=unicode(self.ui.client.itemText(self.ui.client.currentIndex())).split()[0]).one().id
     s.add(ord)
     s.commit()
     s.close()
     self.close()
开发者ID:frolova,项目名称:sc,代码行数:13,代码来源:AddOrderWidget.py

示例13: remove_author

# 需要导入模块: from model import Session [as 别名]
# 或者: from model.Session import close [as 别名]
def remove_author():
	a_id   = request.args.get('id')

	s = Session()
	a = s.query(Author).filter_by(id=a_id).first()

	s.delete(a)
	s.commit()

	s.close()

	return json.dumps({'ok': True, 'msg': ''})
开发者ID:Azurin,项目名称:beta,代码行数:14,代码来源:controller.py

示例14: edit_meal

# 需要导入模块: from model import Session [as 别名]
# 或者: from model.Session import close [as 别名]
def edit_meal(_id):
	s = Session()
	b = s.query(Meal).filter_by(id=_id).first()

	current_products = b.products
	products = s.query(Product).all()

	other_products = []
	for a in products:
		if a not in b.products:
			other_products.append(a)
	s.close()

	return render_template('edit_meal.html', meal=b, other_products=other_products, current_products=current_products)
开发者ID:Azurin,项目名称:kk,代码行数:16,代码来源:controller.py

示例15: edit_book

# 需要导入模块: from model import Session [as 别名]
# 或者: from model.Session import close [as 别名]
def edit_book(_id):
	s = Session()
	b = s.query(Book).filter_by(id=_id).first()

	current_authors = b.authors
	authors = s.query(Author).all()

	other_authors = []
	for a in authors:
		if a not in b.authors:
			other_authors.append(a)
	s.close()

	return render_template('edit_book.html', book=b, other_authors=other_authors, current_authors=current_authors)
开发者ID:Azurin,项目名称:beta,代码行数:16,代码来源:controller.py


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