本文整理匯總了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
示例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
示例3: GetBackbone
def GetBackbone(self):
""" return data for backbone.rdf """
conn = DatabaseManager()
try:
conn.openConnection(self)
except OperationalError, error:
#write log
return ((), 1)
示例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
示例5: getDefinitionSources
def getDefinitionSources(self):
""" return definition sources """
conn = DatabaseManager()
try:
conn.openConnection(self)
except OperationalError, error:
# write log
return ({}, 1)
示例6: GetAllRelations
def GetAllRelations(self):
""" return all relations """
conn = DatabaseManager()
try:
conn.openConnection(self)
except OperationalError, error:
# write log
return ((), 1)
示例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)
示例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
示例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, "")
示例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)
示例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)
示例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)
示例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)
示例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']))
示例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