当前位置: 首页>>代码示例>>Python>>正文


Python dbconnect.DBConnect类代码示例

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


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

示例1: get_tables

 def get_tables(self):
     '''returns all tables required in the from clause for this query.
     '''
     tables = self.get_queried_tables()
     # add the tables required to link the above tables together
     db = DBConnect.getInstance()
     exps = db.get_linking_expressions(tables)
     for exp in exps:
         tables += exp.get_tables()
     return list(set(tables))
开发者ID:daviddao,项目名称:CellProfiler-REST,代码行数:10,代码来源:#sqltools.py

示例2: __init__

    def __init__(self, parent, properties = None, show_controls = True, size=(600, 600), loadData = True, **kwargs):
        wx.Frame.__init__(self, parent, -1, size=size, title='Dimensionality Reduction Plot', **kwargs)
        self.SetName('Plot main')

        if properties is not None:
            global p
            p = properties

            if not p.is_initialized():
                logging.critical('Classifier requires a properties file. Exiting.')
                raise Exception('Classifier requires a properties file. Exiting.')
            global db
            db = DBConnect.getInstance()

        global classifier
        classifier = parent

        if loadData:
            # Define a progress dialog
            dlg = wx.ProgressDialog('Fetching cell data...', '0% Complete', 100, classifier,
                                    wx.PD_ELAPSED_TIME | wx.PD_ESTIMATED_TIME |
                                    wx.PD_REMAINING_TIME | wx.PD_CAN_ABORT)
            def cb(frac):
                cont, skip = dlg.Update(int(frac * 100.), '%d%% Complete'%(frac * 100.))
                if not cont: # cancel was pressed
                    dlg.Destroy()
                    raise StopCalculating()

            # Load the data for each object
            try:
                self.data, self.data_dic = self.load_obj_measurements(cb)
            except StopCalculating:
                self.PostMessage('User canceled updating training set.')
                return
            dlg.Destroy()
        else:
            self.data, self.data_dic = None, None
            
        self.features_dic = self.load_feature_names()
        self.class_masks = None
        self.class_names = None
        self.object_opacity = None

        figpanel = PlotNotebook(self)
        self.figure_scores = figpanel.add('Scores')
        self.figure_loadings = figpanel.add('Loadings')
        self.update_figures()
        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(figpanel, 1, wx.EXPAND)
                
        configpanel = PlotControl(self, self.figure_scores, self.figure_loadings)
        sizer.Add(configpanel, 0, wx.EXPAND | wx.ALL, 5)
        self.SetSizer(sizer)
        self.Centre()
开发者ID:AnneCarpenter,项目名称:CellProfiler-Analyst,代码行数:54,代码来源:dimensredux.py

示例3: extractDataFromGroupsMysql

    def extractDataFromGroupsMysql(self, dependentDataValues, independentDataValues):
        from properties import Properties
        from dbconnect import (
            DBConnect,
            UniqueImageClause,
            UniqueObjectClause,
            GetWhereClauseForImages,
            GetWhereClauseForObjects,
            image_key_columns,
            object_key_columns,
        )
        import sqltools as sql

        p = Properties.getInstance()
        p.LoadFile("C:\\Users\\Dalitso\\Desktop\\workspace2\\abhakar\\Properties_README.txt")
        db = DBConnect.getInstance()

        def buildquery(self, theGroup, var):
            pairs = theGroup.pairsDict
            if var == "dep":
                for i in pairs.keys():
                    print i
                    q = "SELECT " + "`" + self.dependentVariable + "`" + "FROM " + self.table + " WHERE "
                    q2 = [i + " LIKE `" + pairs[i] + "` AND " for i in pairs.keys()]
                    result = q + "".join(q2)[:-4]
                    print result
            if var == "ind":
                for i in pairs.keys():
                    print i
                    q = "SELECT " + "`" + self.independentVariable + "`" + "FROM " + self.table + "WHERE"
                    q2 = [i + "`" + " LIKE `" + pairs[i] + "` AND " for i in pairs.keys()]
                    result = q + "".join(q2)[:-4]
                    print result
            return result

        import numpy as np

        dataDict = {}
        dependentDataValues = np.array(dependentDataValues)
        independentDataValues = np.array(independentDataValues)
        tmp = {}
        for iGrp in self.groupDefinitions:
            theGroup = iGrp
            theGroup.checkMatchCount
            tmp["dependentData"] = db.execute(buildquery(self, theGroup, "dep"))
            tmp["independentData"] = db.execute(buildquery(self, theGroup, "ind"))
            # tmp['pairs'] = theGroup.pairsDict[theGroup.description]
            dataDict[theGroup.description] = tmp
            # print iGrp,theGroup.description,tmp
        return dataDict
开发者ID:dbanda,项目名称:BearlabCellprofiler,代码行数:50,代码来源:dataSelectionObject.py

示例4: get_where_clause

 def get_where_clause(self):
     '''Build the where clause from conditions given by the user and 
     conditions that link all the tables together.
     '''
     db = DBConnect.getInstance()
     conditions = []
     conditions += ['(%s)'%(str(f)) for f in self.filters]
     queried_tables = self.get_queried_tables()
     if len(queried_tables) > 1:
         link_exps = db.get_linking_expressions(queried_tables)
         if link_exps:
             conditions += [str(exp) for exp in link_exps]
     if self.old_filters:
         conditions += ['%s.%s = subquery_%d.%s'%(p.image_table, col, i, col) 
                        for i in range(len(self.old_filters))
                        for col in image_key_columns()]
     if self.wheres:
         conditions += [str(where) for where in self.wheres]
     return ' AND '.join(conditions)
开发者ID:daviddao,项目名称:CellProfiler-REST,代码行数:19,代码来源:#sqltools.py

示例5: PlateViewer

import properties
import logging
import matplotlib.cm
import numpy as np
from itertools import groupby
import os
import sys
import re
import wx
import cpa.helpmenu
import csv

p = properties.Properties.getInstance()
# Hack the properties module so it doesn't require the object table.
properties.optional_vars += ['object_table']
db = DBConnect.getInstance()

required_fields = ['plate_shape', 'well_id']

fixed_width = (200,-1)

class PlateViewer(wx.Frame, CPATool):
    def __init__(self, parent, size=(800,-1), **kwargs):
        wx.Frame.__init__(self, parent, -1, size=size, title='Plate Viewer', **kwargs)
        CPATool.__init__(self)
        self.SetName(self.tool_name)
        self.SetBackgroundColour("white") # Fixing the color

        # Check for required properties fields.
        fail = False
        for field in required_fields:
开发者ID:CellProfiler,项目名称:CellProfiler-Analyst,代码行数:31,代码来源:plateviewer.py

示例6: HTS_GroupDataExtractMySql

def HTS_GroupDataExtractMySql(dataSelector,table):
    from HTS_dataDict import HTS_dataDict
    import xlrd as xl
    import numpy as np
    import matplotlib.pyplot as plt
    from properties import Properties
    from dbconnect import DBConnect, UniqueImageClause, UniqueObjectClause, GetWhereClauseForImages, GetWhereClauseForObjects, image_key_columns, object_key_columns
    import sqltools as sql

    p = Properties.getInstance()
    db = DBConnect.getInstance()
    dependentDataValues = False
    independentDataValues = False
#    def buildquery(self, table):
#        q = 'SELECT ' + self.independentVar + ', '+ self.dependentVar +' FROM ' + table
#        q2= [' WHERE '+ y[1] +' LIKE ' +y[0] for y in group.pairs]
#        return q + ''.join(q2)

    returnDict = HTS_dataDict(dataSelector)
    #for iFile in range(nFiles):
    dataSelector.clearAllIndici
    print('HTS_GroupDataExtract: using sheet %s for %s\n',table)
    query ='SELECT `' + dataSelector.independentVariable + '`  FROM ' + '`' +table+'`'
    print query
    dataSelector.findValidIndiciFromDataColumn(dataSelector.independentVariable,db.execute(query))
    query = 'SELECT `' + dataSelector.dependentVariable + '`  FROM ' + '`' +table+'`'
    print query
    dataSelector.findValidIndiciFromDataColumn(dataSelector.dependentVariable,db.execute(query))
    print dependentDataValues, independentDataValues, "variables"
    if not dependentDataValues:
        print 'HTS_GroupDataExtract: dependent variable not found in %s',
    if not independentDataValues:
        print 'HTS_GroupDataExtract: independent variable not found in %s'
    # print dataSelector.extractDataFromGroups(dependentDataValues,independentDataValues)
    dataSelector.table =  table
    returnDict.dict[table] =  dataSelector.extractDataFromGroupsMysql(dependentDataValues,independentDataValues)



#    if nFiles > 1:
#       # Get data from the selector
#        nGroups = dataSelector.nGroups
#        groupKeys = dataSelector.getGroupDescriptions()
#      # Create the combined group
#        combinedData = {}
#        tmpStruct = {}
#        tmpStruct['dependentData'] = np.array([])
#        tmpStruct['independentData'] = np.array([])
#        for iGrp in range(nGroups):
#            combinedData[groupKeys[iGrp]] = tmpStruct
#        for iFile in range(nFiles):
#            #print('the key = %s\n')
#            fileData = returnDict.dict[dataFiles[iFile]]
#            for iGrp in range(nGroups):
#                grpKey = groupKeys[iGrp]
#                #combDepData = combinedData[grpKey]['dependentData']
#                fileDepData = fileData[grpKey]['dependentData']
#                tmpStruct['dependentData'] = np.concatenate((tmpStruct['dependentData'],fileDepData[:]))
#                #combIndData = [combinedData[grpKey]['independentData']]
#                fileIndData = fileData[grpKey]['independentData']
#                tmpStruct['independentData'] = np.concatenate((tmpStruct['independentData'],fileIndData[:]))
#                combinedData[grpKey] = tmpStruct
#
#        returnDict.dict['combinedData'] = combinedData

    return returnDict
开发者ID:dbanda,项目名称:BearlabCellprofiler,代码行数:66,代码来源:HTS_GroupDataExtractMySql.py

示例7: make_unique_plot_name

            f.write('\n')
        f.close()

    def make_unique_plot_name(self, prefix):
        '''This function must be called to generate a unique name for each plot.
        eg: plot.SetName(wx.GetApp().make_unique_plot_name('Histogram'))
        '''
        plot_num = max([int(plot.Name[len(prefix):]) 
                        for plot in self.plots if plot.Name.startswith(prefix)])
        return '%s %d'%(prefix, plot_num)


if __name__ == "__main__":
    # Initialize the app early because the fancy exception handler
    # depends on it in order to show a dialog.
    app = CPAnalyst(redirect=False)
    if sys.platform=='darwin':
        import bioformats
    # Install our own pretty exception handler unless one has already
    # been installed (e.g., a debugger)
    if sys.excepthook == sys.__excepthook__:
        from errors import show_exception_as_dialog
        sys.excepthook = show_exception_as_dialog

    # Black magic: Bus errors occur on certain Macs if we wait until
    # later to connect, so we'll do it here.
    DBConnect.getInstance().connect()
    
    app.MainLoop()
    os._exit(0)
开发者ID:timesofbadri,项目名称:CellProfiler-Analyst,代码行数:30,代码来源:cpa.py


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