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


Python DatabaseManager.DatabaseManager類代碼示例

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


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

示例1: view

 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,代碼行數:7,代碼來源:noteoperations.py

示例2: concept_as_rdf

 def concept_as_rdf(self, REQUEST, cp, ns="1"):
     """ Return a concept in RDF format """
     conn = DatabaseManager()
     try:
         conn.openConnection(self)
     except OperationalError, error:
         return None
開發者ID:eaudeweb,項目名稱:EionetProducts,代碼行數:7,代碼來源:GimmeThesaurus.py

示例3: GetBackbone

 def GetBackbone(self):
     """ return data for backbone.rdf """
     conn = DatabaseManager()
     try:
         conn.openConnection(self)
     except OperationalError, error:
         #write log
         return ((), 1)
開發者ID:eaudeweb,項目名稱:EionetProducts,代碼行數:8,代碼來源:Concept.py

示例4: delete

 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,代碼行數:8,代碼來源:noteoperations.py

示例5: getDefinitionSources

 def getDefinitionSources(self):
     """ return definition sources """
     conn = DatabaseManager()
     try:
         conn.openConnection(self)
     except OperationalError, error:
         # write log
         return ({}, 1)
開發者ID:eaudeweb,項目名稱:EionetProducts,代碼行數:8,代碼來源:GimmeThesaurus.py

示例6: GetAllRelations

 def GetAllRelations(self):
     """ return all relations """
     conn = DatabaseManager()
     try:
         conn.openConnection(self)
     except OperationalError, error:
         # write log
         return ((), 1)
開發者ID:eaudeweb,項目名稱:EionetProducts,代碼行數:8,代碼來源:GimmeThesaurus.py

示例7: GetLanguageDirection

    def GetLanguageDirection(self, lang):
        """ get a language by its code """

        conn = DatabaseManager()
        try:
            conn.openConnection(self)
        except OperationalError, error:
            # write log
            return ({}, 1)
開發者ID:eaudeweb,項目名稱:EionetProducts,代碼行數:9,代碼來源:GimmeThesaurus.py

示例8: GetLanguages

    def GetLanguages(self, concept_ns=None, concept_id=None):
        """ get languages """

        conn = DatabaseManager()
        try:
            conn.openConnection(self)
        except OperationalError, error:
            # write log
            return None
開發者ID:eaudeweb,項目名稱:EionetProducts,代碼行數:9,代碼來源:GimmeThesaurus.py

示例9: getAlphabet

 def getAlphabet(self, lang, theme, case, theme_ns=""):
     """ return the alphabet (default small letters) for a given language """
     conn = DatabaseManager()
     try:
         conn.openConnection(self)
     except OperationalError, error:
         # write log
         conn.closeConnection()
         return ((), [], 1, "")
開發者ID:eaudeweb,項目名稱:EionetProducts,代碼行數:9,代碼來源:GimmeThesaurus.py

示例10: GetConceptName

    def GetConceptName(self, concept_ns, concept_id, langcode):
        """ return a concepts name in requested language """

        conn = DatabaseManager()
        try:
            conn.openConnection(self)
        except OperationalError, error:
            #write log
            return (0, 1)
開發者ID:eaudeweb,項目名稱:EionetProducts,代碼行數:9,代碼來源:Concept.py

示例11: GetConceptsName

    def GetConceptsName(self, langcode, start=0, letter=0, ns=1):
        """ return the concepts name for a given language """

        conn = DatabaseManager()
        try:
            conn.openConnection(self)
        except OperationalError, error:
            #write log
            return ((), [], 1)
開發者ID:eaudeweb,項目名稱:EionetProducts,代碼行數:9,代碼來源:Concept.py

示例12: GetGroupsAndThemes

 def GetGroupsAndThemes(self, langcode):
     """ return all the groups and all the themes for a given language """
     errors = 0
     conn = DatabaseManager()
     try:
         conn.openConnection(self)
     except OperationalError, err:
         # write log
         errors = 1
         return ((), (), (), err)
開發者ID:eaudeweb,項目名稱:EionetProducts,代碼行數:10,代碼來源:GimmeThesaurus.py

示例13: GetGroupConcepts

    def GetGroupConcepts(self, params, langcode=None, REQUEST=None):
        """ return all the narrower concepts beloging to a group """

        relations = []
        top_cp = []

        conn = DatabaseManager()
        try:
            conn.openConnection(self)
        except OperationalError, error:
            self.error_log.raising(sys.exc_info())
            return ((), 1)
開發者ID:eaudeweb,項目名稱:EionetProducts,代碼行數:12,代碼來源:Group.py

示例14: main

def main(argv):
	opts = get_command_args(argv)
	dm = DatabaseManager()

	if (opts['data']):
		pprint(dm.get_data(opts['redcap']))
	if (opts['match']):
		pprint(dm.get_matches(opts['redcap'],opts['bool'],opts['value']))
	if (opts['search']):
		pprint(dm.get_searches(opts['redcap'],opts['bool'],opts['value']))

	if (opts['mach']):
		pprint(dm.get_ml_data(opts['redcap']))
開發者ID:CBMIWU,項目名稱:Research_Reproducibility,代碼行數:13,代碼來源:query_redcap.py

示例15: main

def main():

	print "Reading minID"
	fp = open('ids.txt', 'r')
	for line in fp:
		ids = line.strip().split(",")
		minID = ids[0]
		maxID = ids[1]
	fp.close()

	print "minID: ", minID
	print "maxID: ", maxID

	dbm = DatabaseManager()

	print "running query..."

	places = dbm.runQuery("SELECT id, bounding_box FROM Places \
						   WHERE lat_1 IS NULL AND id >= {0} AND id < {1}".format(minID, maxID))

	print "query done!"
	cont = 0.0;

	for row in places:
		try:
			idPlace = row[0]
			bounding_box = row[1]
			tmp = re.sub(r'u\'','\'', bounding_box)
			tmp = re.sub(r'\'','"', tmp)
			obj = json.loads(tmp)
			box_coords = obj['coordinates'][0]
			
			lat_1 = box_coords[0][1]
			long_1 = box_coords[0][0]
			lat_2 = box_coords[1][1]
			long_2 = box_coords[1][0]
			lat_3 = box_coords[2][1]
			long_3 = box_coords[2][0]
			lat_4 = box_coords[3][1]
			long_4 = box_coords[3][0]

			query = u"""UPDATE Places SET lat_1={0}, long_1={1}, lat_2={2}, long_2={3},lat_3={4}, long_3={5}, lat_4={6}, long_4={7} WHERE id = {8}""".format(lat_1, long_1, lat_2, long_2, lat_3, long_3, lat_4, long_4, idPlace)
			
			print cont

			dbm.runCommit(query)

		except Exception as e:
			print "error with id=", row[0]
			print e
		cont += 1
開發者ID:vdeleon,項目名稱:twitterSentimentAnalyzer,代碼行數:51,代碼來源:transformPlaces.py


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