本文整理匯總了Python中app.model.DBSession.execute方法的典型用法代碼示例。如果您正苦於以下問題:Python DBSession.execute方法的具體用法?Python DBSession.execute怎麽用?Python DBSession.execute使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類app.model.DBSession
的用法示例。
在下文中一共展示了DBSession.execute方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: getNextSeq
# 需要導入模塊: from app.model import DBSession [as 別名]
# 或者: from app.model.DBSession import execute [as 別名]
def getNextSeq(seqname):
"""
Return the next value from a database sequence given the sequence name
@param seqname: Name of sequence
@type seqname: str
@return: the next value from the database sequence
@rtype: int
"""
return DBSession.execute(text("select nextval(:seqname) as myseq"), { 'seqname' : seqname}).fetchone()['myseq']
示例2: generateMolRegId
# 需要導入模塊: from app.model import DBSession [as 別名]
# 或者: from app.model.DBSession import execute [as 別名]
def generateMolRegId(prefixId):
"""
Generate the next reg ID in a sequence for a molecule, given the prefix Id
@param prefixId: The ID of the prefix used for the reg ID
@type prefixId: int
@return: generated reg ID
@rtype: str
"""
log.debug('Retrieving mol_prefix_name for %d' % int(prefixId))
prefix = DBSession.execute(text('select mol_prefix_name from mol_prefix where mol_prefix_id = :prefix_id'), { 'prefix_id' : prefixId}).fetchone()['mol_prefix_name']
seq = getNextSeq('regseq_' + prefix)
mol_reg_id = prefix + "-" + str(seq)
log.debug('Generated mol registration ID of %s' % mol_reg_id)
return mol_reg_id
示例3: testCompareSmartsToMDL
# 需要導入模塊: from app.model import DBSession [as 別名]
# 或者: from app.model.DBSession import execute [as 別名]
def testCompareSmartsToMDL(self):
"""Can compare a SMARTS pattern to an MDL Mol string"""
r=DBSession.execute(text("select chem.compareSmartsToMol('c', :molstr) as comp"), dict(molstr=self.molstr)).fetchone()
ok_(r['comp'], 'SMARTS pattern failed to match MDL Mol string')
示例4: testCompareSmartsToSmiles
# 需要導入模塊: from app.model import DBSession [as 別名]
# 或者: from app.model.DBSession import execute [as 別名]
def testCompareSmartsToSmiles(self):
"""Can compare a SMARTS pattern to a SMILES string"""
r=DBSession.execute(text("select chem.compareSmartsToSmiles('c', 'c1ccccc1') as comp")).fetchone()
ok_(r['comp'], 'SMARTS pattern failed to match SMILES string')