def test_db(): try: pinners = Table('pinners', metadata, autoload=True) except sqlalchemy.exc.NoSuchTableError: war("no pinners table") create_tables() load_tables() try: pinners = Table('pinners', metadata, autoload=True) except: err("could not open pinners table") exit(-1) contents = Table('contents', metadata, autoload=True) complaints = Table('complaints', metadata, autoload=True) reviewers = Table('reviewers', metadata, autoload=True) rs = pinners.select() run(rs, text='pinners') rs = contents.select() run(rs, text='contents') rs = complaints.select() run(rs, text='complaints') rs = reviewers.select() run(rs, text='reviewers') rs = join(pinners, contents).select() run(rs, text='join contents') rs = select([pinners.c.name, contents.c.url], and_(pinners.c.name == 'Mary', pinners.c.pinner_id == contents.c.pinner_id)) run(rs, text='Mary contents') rs = select([pinners.c.pinner_id, contents.c.url, contents.c.content_id], \ and_(pinners.c.pinner_id == 3, pinners.c.pinner_id == contents.c.pinner_id)) run(rs, text='3 contents')
userservice = UserService.get_instance() print('#########################################') print('# #') print('# 欢迎登录51reboot人员管理系统 #') print('# #') print('#########################################') while True: username = input('请输入用户名:') password = input('请输入密码:') ret = userservice.login(username, password) if ret[0] == -1: print('用户名或密码错误,一天只有三次机会,您没有机会了!') logging.war( '##################用户名或密码错误,一天只有三次机会,您没有机会了!##################') exit(0) elif ret[0] == 0: print('用户名或密码错误,还剩{}次机会!'.format(ret[1])) logging.war('用户名或密码错误,还剩{}次机会!'.format(ret[1])) continue print('#########################################') print('# #') print('# 请选择编号: #') print('# [1]添加 #') print('# [2]删除 #') print('# [3]修改 #') print('# [4]查询 #') print('# [5]搜索 #')
async def remove(self): args = [self.getValue(self.__primary_key__)] rows = await.execute(self.__delete__, args) if rows != 1: logging.war('failed to remove by primary key: affected rows: %s' % rows)
async def update(self): args = list(map(self.getValue, self.__fields__)) args.append(slef.getValue(slef.__primary_key__)) rows = await execute(self.__update__, args) if rows != 1: logging.war('failed to update by primay key: affected rows: %s' % rows)