smart_module.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:hapi 作者: mayaculpa 项目源码 文件源码
def load_influx_settings(self):
        """Load Influxdb server information stored in database base."""
        try:
            settings = {}
            field_names = '''
                server
                port
                username
                password
            '''.split()
            sql = 'SELECT {fields} FROM influx_settings LIMIT 1;'.format(
                fields=', '.join(field_names))
            database = sqlite3.connect(utilities.DB_CORE)
            db_elements = database.cursor().execute(sql).fetchone()
            for field, value in zip(field_names, db_elements):
                settings[field] = value
            self.ifconn = InfluxDBClient(
                settings["server"], settings["port"], settings["username"], settings["password"]
            )
            Log.info("Influxdb information loaded.")
        except Exception as excpt:
            Log.exception("Trying to load Influx server information: %s.", excpt)
        finally:
            database.close()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号