• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python mydb.close_db函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中mydb.close_db函数的典型用法代码示例。如果您正苦于以下问题:Python close_db函数的具体用法?Python close_db怎么用?Python close_db使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: store_message_in_database

def store_message_in_database(_from, _to, msg):
    mydb.open()
    ISOTIMEFORMAT='%Y-%m-%d %X'
    createdTime=str(time.strftime( ISOTIMEFORMAT, time.localtime() ))
    result = mydb.insert_db('insert into message(_from,_to,msg,createdAt) values(?,?,?,?)',
                            [_from,_to,msg,createdTime])
    mydb.close_db()
开发者ID:YunNeverMore,项目名称:TreeNetwork-Learning-Website,代码行数:7,代码来源:SendMessage.py


示例2: delete_pattern

def delete_pattern(pattern_id):
    mydb.open()
    mydb.delete_db('delete from edge where _from = ? or _to = ?',[pattern_id, pattern_id])
    mydb.delete_db('delete from pattern where pid=?', [pattern_id])
    mydb.delete_db('delete from node where pid=? and node_index = 1', [pattern_id])
    mydb.close_db()
    return True
开发者ID:YunNeverMore,项目名称:TreeNetwork-Learning-Website,代码行数:7,代码来源:netModel.py


示例3: generate_graph

def generate_graph():
    mydb.open()
    graph= dict()
    query = 'select * from edge'
    result = mydb.query_db(query, one = False)
    mydb.close_db()
    inactive_pid_list=SendMessage.find_all_inactive_pid()
    if not result==None:
        for r in result:
            f=r['_from']
            t=r['_to']
            if not f in inactive_pid_list and not t in inactive_pid_list:
                # if the key is not exist in the graph
                if f not in graph:
                   graph[f]=[t]
                else:
                   temp_List=graph[f]
                   temp_List.append(t)
                if t not in graph:
                    graph[t]=[f]
                else:
                    temp_List=graph[t]
                    temp_List.append(f)
                # print str(r['_from'])+' to '+ str(r['_to'])
    return graph
开发者ID:YunNeverMore,项目名称:TreeNetwork-Learning-Website,代码行数:25,代码来源:PathFinder.py


示例4: delete_pattern

def delete_pattern(pattern_id):
    mydb.open()
    nodes = mydb.query_db('SELECT * FROM node WHERE pid = ?',[pattern_id])
    if len(nodes) > 1:
        return False
    prohibited_node = []
    results = mydb.query_db('SELECT * FROM pattern')
    for p in results:
        pid = p['pid']
        re1 = mydb.query_db('SELECT * FROM edge WHERE _from = ?',[pid])
        re2 = mydb.query_db('SELECT * FROM edge WHERE _to = ?',[pid])
        if len(re1)+len(re2) == 1:
            if len(re1) == 1:
                pro = re1[0]['_to']
            else:
                pro = re2[0]['_from']
            prohibited_node.append(pro)
    print prohibited_node
    if pid in prohibited_node:
        mydb.close_db()
        return False
    else:
        mydb.delete_db('delete from edge where _from = ? or _to = ?',[pattern_id, pattern_id])
        mydb.delete_db('delete from pattern where pid=?', [pattern_id])
        mydb.delete_db('delete from node where pid=? and node_index = 1', [pattern_id])
        mydb.close_db()
        return True
开发者ID:csh130,项目名称:treeNet,代码行数:27,代码来源:netModel.py


示例5: one_pattern_edge

def one_pattern_edge(pid):
    edges = []
    mydb.open()
    results = mydb.query_db('SELECT * FROM edge WHERE _from = ?', [pid])
    for e in results:
        edges.append(e['_to'])
    mydb.close_db()
    return edges
开发者ID:csh130,项目名称:treeNet,代码行数:8,代码来源:netModel.py


示例6: add_connection

def add_connection(nid1,nid2):
    mydb.open()
    p1 = mydb.query_db('SELECT * FROM node WHERE nid = ?', [nid1], one = True)
    p2 = mydb.query_db('SELECT * FROM node WHERE nid = ?', [nid2], one = True)
    mydb.insert_db('INSERT INTO  edge(_from, _to) VALUES (?,?)', [p1['pid'], p2['pid']])

    mydb.close_db()
    pass
开发者ID:YunNeverMore,项目名称:TreeNetwork-Learning-Website,代码行数:8,代码来源:netModel.py


示例7: change_pwd

def change_pwd(username,pwd):
    mydb.open()
    result=_valid_login_format(username,pwd)
    if not result==None:
        return result
    mydb.insert_db("""update account set pwd=? WHERE username= ?""", [pwd, username])
    mydb.close_db()
    return None
开发者ID:spike1390,项目名称:treeNet,代码行数:8,代码来源:accessControl.py


示例8: delete_connection

def delete_connection(nid1,nid2):
    mydb.open()
    p1 = mydb.query_db('SELECT * FROM node WHERE nid = ?', [nid1], one = True)
    p2 = mydb.query_db('SELECT * FROM node WHERE nid = ?', [nid2], one = True)
    mydb.delete_db('delete from edge where _from = ? and _to = ?',[p1['pid'], p2['pid']])
    mydb.delete_db('delete from edge where _from = ? and _to = ?',[p2['pid'], p1['pid']])
    mydb.close_db()
    pass
开发者ID:YunNeverMore,项目名称:TreeNetwork-Learning-Website,代码行数:8,代码来源:netModel.py


示例9: add_node

def add_node(pid,index):
    mydb.open()
    results = mydb.query_db('SELECT * FROM node WHERE pid = ? and node_index = ?', [pid, index/2] )
    if len(results)!=0:
        nid = mydb.insert_db('INSERT INTO node (pid,node_index,active) VALUES (?,?,1)',[pid,index])
        mydb.close_db()
        return nid
    else:
        return -1
开发者ID:YunNeverMore,项目名称:TreeNetwork-Learning-Website,代码行数:9,代码来源:netModel.py


示例10: get_node_byID

def get_node_byID(nid):
    mydb.open()
    # active =1 means it is active
    result = mydb.query_db('select pid,node_index from node WHERE nid=?',[nid], one=True)
    mydb.close_db()
    if result:
        # we only need pid, and node index for a node to find a path
        node=Node(nid,result['pid'],result['node_index'])
    return node
开发者ID:csh130,项目名称:treeNet,代码行数:9,代码来源:SendMessage.py


示例11: change_security_question

def change_security_question(index, q, a, username):
    if len(a) == 0:
        return -1
    mydb.open()
    query = 'update account set sq_%d= ?,as_%d=? WHERE username = ?' % (index, index)
    print query
    mydb.insert_db(query, [q, a, username])
    mydb.close_db()
    return 1
开发者ID:spike1390,项目名称:treeNet,代码行数:9,代码来源:accessControl.py


示例12: get_security_question

def get_security_question(username):
    mydb.open()
    result = mydb.query_db('select * from account WHERE username = ? ', [username], one=True)
    mydb.close_db()
    if result:
        questions = question(result['sq_1'],result['as_1'],result['sq_2'],result['as_2'],result['sq_3'],result['as_3'])
        return questions
    else:
        return None
开发者ID:spike1390,项目名称:treeNet,代码行数:9,代码来源:accessControl.py


示例13: add_pattern

def add_pattern(ps):
    mydb.open()
    pid = mydb.insert_db('INSERT INTO pattern (creator) VALUES (?)',['spikewang'])
    print pid
    nid = mydb.insert_db('INSERT INTO node (pid,node_index,active) VALUES (?,1,1)', [pid])
    for p in ps:
        mydb.insert_db('INSERT INTO  edge(_from, _to) VALUES (?,?)',[pid,p])
    mydb.close_db()
    return (pid, nid)
开发者ID:csh130,项目名称:treeNet,代码行数:9,代码来源:netModel.py


示例14: get_all_users

def get_all_users():
    mydb.open()
    result = mydb.query_db('select * from account WHERE type = 0',[],one=False)
    mydb.close_db()
    userList=[]
    for user in result:
       dict = {'name':user['username'],'fname':user['fname'],'lname':user['lname']}
       userList.append(dict)
    return userList
开发者ID:spike1390,项目名称:treeNet,代码行数:9,代码来源:accessControl.py


示例15: transform_to_nidList

def transform_to_nidList(pid, path):
    nidList=[]
    mydb.open()
    for index in path:
        query='select nid from node WHERE pid=? AND node_index= ?'
        result = mydb.query_db(query,[str(pid),index], one = True)
        if not result==None:
            nidList.append(result['nid'])
    mydb.close_db()
    return nidList
开发者ID:csh130,项目名称:treeNet,代码行数:10,代码来源:PathFinder.py


示例16: add_pattern

def add_pattern(ps, did):
    mydb.open()
    d_pattern = mydb.query_db('SELECT * FROM pattern WHERE did = ? and isDomain = 1', [did], one = True)
    pid = mydb.insert_db('INSERT INTO pattern (did, isDomain) VALUES (?,0)', [did])
    nid = mydb.insert_db('INSERT INTO node (pid,node_index,active) VALUES (?,1,1)', [pid])
    mydb.insert_db('INSERT INTO  edge(_from, _to) VALUES (?,?)', [pid, d_pattern['pid']])
    for p in ps:
        mydb.insert_db('INSERT INTO  edge(_from, _to) VALUES (?,?)',[pid,p])
    mydb.close_db()
    return (pid, nid)
开发者ID:YunNeverMore,项目名称:TreeNetwork-Learning-Website,代码行数:10,代码来源:netModel.py


示例17: find_all_inactive_pid

def find_all_inactive_pid():
    mydb.open()
    # active =1 means it is active
    result = mydb.query_db('select pid from node WHERE active=0 AND node_index=1', one=False)
    mydb.close_db()
    pidList=[]
    if result:
        for node in result:
            pidList.append(node['pid'])
    return pidList
开发者ID:YunNeverMore,项目名称:TreeNetwork-Learning-Website,代码行数:10,代码来源:SendMessage.py


示例18: find_all_inactiveNode

def find_all_inactiveNode():
    mydb.open()
    # active =1 means it is active
    result = mydb.query_db('select * from node WHERE active=0', one=False)
    mydb.close_db()
    nidList=[]
    if result:
        for nid in result:
            nidList.append(nid['nid'])
    return nidList
开发者ID:YunNeverMore,项目名称:TreeNetwork-Learning-Website,代码行数:10,代码来源:SendMessage.py


示例19: return_p_edges

def return_p_edges():
    edges = []
    mydb.open()
    results = mydb.query_db('SELECT * FROM edge ')
    for e in results:
        source = e['_from']
        target = e['_to']
        tmp_edge = edge(source, target)
        edges.append(tmp_edge)
    mydb.close_db()
    return edges
开发者ID:csh130,项目名称:treeNet,代码行数:11,代码来源:netModel.py


示例20: delete_domain

def delete_domain(pid, did):
    mydb.open()
    d_pattern = mydb.query_db('SELECT * FROM pattern WHERE did = ? and isDomain = 1', [did], one = True)
    mydb.delete_db('delete from edge where _from = ? or _to = ?',[d_pattern['pid'], d_pattern['pid']])
    mydb.delete_db('delete from domain where did=?', [did])
    mydb.delete_db('delete from pattern where pid=?', [d_pattern['pid']])
    mydb.delete_db('delete from node where pid=?', [d_pattern['pid']])
    mydb.delete_db('delete from pattern where pid=?', [pid])
    mydb.delete_db('delete from node where pid=?', [pid])
    mydb.close_db()
    return True
开发者ID:YunNeverMore,项目名称:TreeNetwork-Learning-Website,代码行数:11,代码来源:netModel.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python mydb.open函数代码示例发布时间:2022-05-27
下一篇:
Python logger.error函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap