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


Python Document.delete方法代码示例

本文整理汇总了Python中Document.Document.delete方法的典型用法代码示例。如果您正苦于以下问题:Python Document.delete方法的具体用法?Python Document.delete怎么用?Python Document.delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Document.Document的用法示例。


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

示例1: __init__

# 需要导入模块: from Document import Document [as 别名]
# 或者: from Document.Document import delete [as 别名]
class DBlink:
    '''
    This class links the others classes with a database. The database's informations are into the document 
    'config.txt' rappresenting by class Document called config.
    '''
    
    def __init__(self):
        '''
        Initialization of object Document for configuration data and all default info
        '''
        self.config=Document("config.txt")
        self.default_host='www.medcordex.eu'
        self.default_user='sagitta'
        self.default_passwd='sagitta'
        self.default_db='medcordex'
        
    def set_config(self,params):
        '''
        Set new params of config Document
        @param params: dictionary
        '''
        self.config.update(params)
    
    def get_config_toString(self):
        '''
        Take the params of config Document
        @return params: string, params of config Document
        '''
        return self.config.toString()
    
    def del_config(self):
        '''
        Delete all info of the config Document
        '''
        self.config.delete()
        
    def get_doc(self):
        '''
        @return config: Document object, config Document
        '''
        return self.config
    
    def get_table(self):
        '''
        @return table: string, table info into config Document
        '''
        return self.config.get_parameter("table")
    
    def get_db(self):
        '''
        @return db: string, db info into config Document
        '''
        return self.config.get_parameter("db")
    
    def get_url(self):
        '''
        @return url info: string token by 'config' Document. If url is a void string and the host info is equals 
        to www.medcordex.eu return the default url for medcordex users.
        '''
        url= self.config.get_parameter("url")
        if url=="":
            #default url for medcordex users
            if self.config.get_parameter("host")=="www.medcordex.eu":
                url="ftp://"+self.config.get_parameter("user")+":"+self.config.get_parameter("passwd")+"@"+self.config.get_parameter("host")+"/ALL/"
        return url
        
    def send_query(self,query):
        '''
        Send query using mysql.connector module. To send the query, the function needs the informations
        host, user, passwd and db token by 'config' Document. If the host and db info are void string, the function send the query
        to default info.
        @param query: string in form like SELECT fields FROM table WHERE conditions
        @return tuple: query response
        '''
        if self.config.get_parameter("host")=='' and self.config.get_parameter('db')=='':
            # default configuration for medcordex users
            database=mysql.connect(host=self.default_host,
                                     user=self.default_user,
                                     passwd=self.default_passwd,
                                     db=self.default_db)
        else:
            # personal configuration for all other cases
            database=mysql.connect(host=self.config.get_parameter("host"),
                                     user=self.config.get_parameter("user"),
                                     passwd=self.config.get_parameter("passwd"),
                                     db=self.config.get_parameter("db"))
        cursore=database.cursor()
        cursore.execute(query)
        return cursore.fetchall()
开发者ID:ClaudioR3,项目名称:workspace,代码行数:91,代码来源:DBlink.py


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