當前位置: 首頁>>代碼示例>>Python>>正文


Python DatabaseManager.query方法代碼示例

本文整理匯總了Python中DatabaseManager.DatabaseManager.query方法的典型用法代碼示例。如果您正苦於以下問題:Python DatabaseManager.query方法的具體用法?Python DatabaseManager.query怎麽用?Python DatabaseManager.query使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在DatabaseManager.DatabaseManager的用法示例。


在下文中一共展示了DatabaseManager.query方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: delete

# 需要導入模塊: from DatabaseManager import DatabaseManager [as 別名]
# 或者: from DatabaseManager.DatabaseManager import query [as 別名]
 def delete(self, noteid="", allnotes="one"):
     dbmgr = DatabaseManager("scribler.db")
     if allnotes == "one":
         status = dbmgr.query(
             "delete from notes where _id = '" + noteid + "'")
     else:
         status = dbmgr.query("delete from notes")
     return status.rowcount
開發者ID:JackMwangi,項目名稱:Scrible,代碼行數:10,代碼來源:noteoperations.py

示例2: searchThesaurus

# 需要導入模塊: from DatabaseManager import DatabaseManager [as 別名]
# 或者: from DatabaseManager.DatabaseManager import query [as 別名]
    def searchThesaurus(self, term, langcode='en', ns=1):
        """ """
        if not term:
            return []

        conn = DatabaseManager()
        conn.openConnection(self)

        collation = self._get_language_collation(langcode, conn)
        err, res, msg = conn.query(sql_find_concept(term, langcode, collation))
        if err:
            # log error
            return []

        conn.closeConnection()

        results = []
        for i in res:
            if i['scope_name'] is None:
                i['scope_name'] = ''
            if i['concept_alt_name'] is None:
                i['concept_alt_name'] = ''
            results.append(ConceptLink(ns, i['concept_id'], i['concept_name'], i['scope_name'], i['concept_alt_name']))

        return results
開發者ID:eaudeweb,項目名稱:EionetProducts,代碼行數:27,代碼來源:Concept.py

示例3: view

# 需要導入模塊: from DatabaseManager import DatabaseManager [as 別名]
# 或者: from DatabaseManager.DatabaseManager import query [as 別名]
 def view(self, noteid=""):
     notetext = {}
     dbmgr = DatabaseManager("scribler.db")
     for row in dbmgr.query("select * from notes where _id = '" + noteid + "'"):
         notetext["title"] = row[1]
         notetext["body"] = row[2]
     return notetext
開發者ID:JackMwangi,項目名稱:Scrible,代碼行數:9,代碼來源:noteoperations.py

示例4: fetch_concept_property_translations

# 需要導入模塊: from DatabaseManager import DatabaseManager [as 別名]
# 或者: from DatabaseManager.DatabaseManager import query [as 別名]
    def fetch_concept_property_translations(self, concept_ns, concept_id, prop_name):
        conn = DatabaseManager()
        conn.openConnection(self)

        err, res, msg = conn.query(sql_get_concept_property(concept_ns, concept_id, prop_name))
        if err:
            print err, msg

        conn.closeConnection()
        return res
開發者ID:eaudeweb,項目名稱:EionetProducts,代碼行數:12,代碼來源:Concept.py

示例5: fetch_namespaces

# 需要導入模塊: from DatabaseManager import DatabaseManager [as 別名]
# 或者: from DatabaseManager.DatabaseManager import query [as 別名]
    def fetch_namespaces(self):
        conn = DatabaseManager()
        conn.openConnection(self)

        err, res, msg = conn.query(sql_get_namespaces())
        if err:
            print err, msg

        conn.closeConnection()
        return res
開發者ID:eaudeweb,項目名稱:EionetProducts,代碼行數:12,代碼來源:Concept.py

示例6: _get_concept_relatives

# 需要導入模塊: from DatabaseManager import DatabaseManager [as 別名]
# 或者: from DatabaseManager.DatabaseManager import query [as 別名]
    def _get_concept_relatives(self, concept_ns, concept_id, target_ns=None, relation_uri=None):
        """ get all concepts related to a given concept """
        conn = DatabaseManager()
        conn.openConnection(self)

        err, res, msg = conn.query(sql_get_concept_relatives(concept_ns, concept_id, target_ns, relation_uri))

        conn.closeConnection()

        return res
開發者ID:eaudeweb,項目名稱:EionetProducts,代碼行數:12,代碼來源:Concept.py

示例7: fetch_concept_languages

# 需要導入模塊: from DatabaseManager import DatabaseManager [as 別名]
# 或者: from DatabaseManager.DatabaseManager import query [as 別名]
    def fetch_concept_languages(self, concept_ns, concept_id):
        conn = DatabaseManager()
        conn.openConnection(self)

        err, res, msg = conn.query(sql_get_concept_languages(concept_ns, concept_id))
        if err:
            print err, msg

        conn.closeConnection()

        return res
開發者ID:eaudeweb,項目名稱:EionetProducts,代碼行數:13,代碼來源:Concept.py

示例8: fetch_concept_by_regex

# 需要導入模塊: from DatabaseManager import DatabaseManager [as 別名]
# 或者: from DatabaseManager.DatabaseManager import query [as 別名]
    def fetch_concept_by_regex(self, namespace_id, regex, language):
        conn = DatabaseManager()
        conn.openConnection(self)

        err, res, msg = conn.query(sql_get_concept_by_regex(namespace_id, regex, language))
        if err:
            print err, msg

        conn.closeConnection()

        return res
開發者ID:eaudeweb,項目名稱:EionetProducts,代碼行數:13,代碼來源:Concept.py

示例9: searchskip

# 需要導入模塊: from DatabaseManager import DatabaseManager [as 別名]
# 或者: from DatabaseManager.DatabaseManager import query [as 別名]
    def searchskip(self, query="", limit=1, offset=1):
        listtext = []
        dbmgr = DatabaseManager("scribler.db")
        if limit == 1:
            for row in dbmgr.query("select * from notes where title LIKE '%" + query + "%' or content LIKE '%" + query + "%'"):
                notetext = {}
                notetext["_id"] = row[0]
                notetext["title"] = row[1]
                notetext["body"] = row[2]
                notetext["datecreated"] = row[4]
                listtext.append(notetext)
        elif limit > 1:
            for row in dbmgr.query("select * from notes where title LIKE '%" + query + "%' or content LIKE '%" + query + "%' limit '" + str(limit) + "' OFFSET '" + str(offset) + "'"):
                notetext = {}
                notetext["_id"] = row[0]
                notetext["title"] = row[1]
                notetext["body"] = row[2]
                notetext["datecreated"] = row[4]
                listtext.append(notetext)

        return listtext
開發者ID:JackMwangi,項目名稱:Scrible,代碼行數:23,代碼來源:noteoperations.py

示例10: CrudOperations

# 需要導入模塊: from DatabaseManager import DatabaseManager [as 別名]
# 或者: from DatabaseManager.DatabaseManager import query [as 別名]
class CrudOperations(object):
    dbmgr = None

    def __init__(self):  # constructor initiates database connection instance
        self.dbmgr = DatabaseManager("cmapp.db")

        """Performs insert in db to save a notetext
        """

    def save(self, **content):  # content contains the name and mobile number of contacts
        contactname = ""
        contactnumber = ""
        if len(content) == 2:
            # Both name and mobile number exist
            contactname = content['contactname']
            contactnumber = content['contactnumber']
        elif len(content) == 1:  # only title exists
            return "Cannot save to db only one argument provided , two are expected"
        # save to db
        self.dbmgr.query(
            "insert into contactsDB(Contactname,Content,sent,datecreated) VALUES('" + contactname + "','" + contactnumber + "','NO','" + self.gettime() + "')")
開發者ID:crakama,項目名稱:ContactsManager,代碼行數:23,代碼來源:crudoperations.py

示例11: viewallskip

# 需要導入模塊: from DatabaseManager import DatabaseManager [as 別名]
# 或者: from DatabaseManager.DatabaseManager import query [as 別名]
    def viewallskip(self, limit=1, offset=1):
        listtext = []
        dbmgr = DatabaseManager("scribler.db")
        if limit == 1:
            for row in dbmgr.query("select * from notes"):
                notetext = {}
                notetext["_id"] = row[0]
                notetext["title"] = row[1]
                notetext["body"] = row[2]
                notetext["datecreated"] = row[4]
                listtext.append(notetext)
        elif limit > 1:
            for row in dbmgr.query("select * from notes limit '" + str(limit) + "' OFFSET '" + str(offset) + "'"):
                notetext = {}
                notetext["_id"] = row[0]
                notetext["title"] = row[1]
                notetext["body"] = row[2]
                notetext["datecreated"] = row[4]
                listtext.append(notetext)

        return listtext
開發者ID:JackMwangi,項目名稱:Scrible,代碼行數:23,代碼來源:noteoperations.py

示例12: fetch_concept

# 需要導入模塊: from DatabaseManager import DatabaseManager [as 別名]
# 或者: from DatabaseManager.DatabaseManager import query [as 別名]
    def fetch_concept(self, concept_id, concept_ns, language):
        conn = DatabaseManager()
        conn.openConnection(self)

        err, res, msg = conn.query(sql_get_concept(concept_id, concept_ns, language))
        if err:
            print err, msg

        conn.closeConnection()
        if len(res) > 0:
            return res[0]
        return None
開發者ID:eaudeweb,項目名稱:EionetProducts,代碼行數:14,代碼來源:Concept.py

示例13: viewall

# 需要導入模塊: from DatabaseManager import DatabaseManager [as 別名]
# 或者: from DatabaseManager.DatabaseManager import query [as 別名]
    def viewall(self, limit=1):
        listtext = []
        dbmgr = DatabaseManager("scribler.db")
        if limit == 1:
            for row in dbmgr.query("select * from notes"):
                notetext = {}
                notetext["_id"] = row[0]
                notetext["title"] = row[1]
                notetext["body"] = row[2]
                notetext["datecreated"] = row[4]
                listtext.append(notetext)
        elif limit > 1:

            for row in dbmgr.query("select * from notes limit '" + str(limit) + "'"):
                notetext = {}
                notetext["_id"] = row[0]
                notetext["title"] = row[1]
                notetext["body"] = row[2]
                notetext["datecreated"] = row[4]
                listtext.append(notetext)

        return listtext  # list containing dictionary entries of notes
開發者ID:JackMwangi,項目名稱:Scrible,代碼行數:24,代碼來源:noteoperations.py

示例14: GetConceptsInfo

# 需要導入模塊: from DatabaseManager import DatabaseManager [as 別名]
# 或者: from DatabaseManager.DatabaseManager import query [as 別名]
    def GetConceptsInfo(self, langcode, ns=1, REQUEST=None):
        """ return the concept name and the concept definition for a given language """
        conn = DatabaseManager()
        conn.openConnection(self)

        err, res, msg = conn.query(sql_get_all_concepts_name(ns, langcode))

        conn.closeConnection()

        if err:
            return ((), 1)

        return res
開發者ID:eaudeweb,項目名稱:EionetProducts,代碼行數:15,代碼來源:Concept.py

示例15: _get_group

# 需要導入模塊: from DatabaseManager import DatabaseManager [as 別名]
# 或者: from DatabaseManager.DatabaseManager import query [as 別名]
    def _get_group(self, id, lang, conn=None):
        """ get group info """
        destroy = 0
        if conn is None:
            destroy = 1
            conn = DatabaseManager()
            conn.openConnection(self)

        err, res, msg = conn.query(sql_get_group_name(id, lang))

        if destroy:
            conn.closeConnection()
            conn = None

        if err:
            raise DatabaseError, msg

        return res
開發者ID:eaudeweb,項目名稱:EionetProducts,代碼行數:20,代碼來源:Group.py


注:本文中的DatabaseManager.DatabaseManager.query方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。