本文整理汇总了Python中DataDB.setConnectionString方法的典型用法代码示例。如果您正苦于以下问题:Python DataDB.setConnectionString方法的具体用法?Python DataDB.setConnectionString怎么用?Python DataDB.setConnectionString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataDB
的用法示例。
在下文中一共展示了DataDB.setConnectionString方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: import DataDB [as 别名]
# 或者: from DataDB import setConnectionString [as 别名]
def main():
parser = ArgumentParser(description='PGObserver Frontend')
parser.add_argument('-c', '--config', help='Path to config file. (default: %s)' % DEFAULT_CONF_FILE, dest='config',
default=DEFAULT_CONF_FILE)
parser.add_argument('-p', '--port', help='server port', dest='port', type=int)
args = parser.parse_args()
args.config = os.path.expanduser(args.config)
if not os.path.exists(args.config):
print 'Configuration file missing:', args.config
parser.print_help()
return
with open(args.config, 'rb') as fd:
settings = json.load(fd)
conn_string = ' '.join((
'dbname=' + settings['database']['name'],
'host=' + settings['database']['host'],
'user=' + settings['database']['frontend_user'],
'password=' + settings['database']['frontend_password'],
'port=' + str(settings['database']['port']),
))
print 'Setting connection string to ... ' + conn_string
DataDB.setConnectionString(conn_string)
if 'logfiles' in settings:
logdata.setFilter(settings['logfiles']['liveuserfilter'])
current_dir = os.path.dirname(os.path.abspath(__file__))
conf = {'global': {'server.socket_host': '0.0.0.0', 'server.socket_port': args.port or settings.get('frontend',
{}).get('port') or 8080}, '/': {'tools.staticdir.root': current_dir},
'/static': {'tools.staticdir.dir': 'static', 'tools.staticdir.on': True}}
tplE.setup(settings)
root = None
for h in hosts.getHostData().values():
mf = MonitorFrontend.MonitorFrontend(h['host_id'])
if root == None:
root = mf
setattr(root, h['uishortname'], mf)
root.report = report.Report()
root.export = export.Export()
root.perftables = performance.PerfTables()
root.perfapi = performance.PerfApi()
root.perfindexes = performance.PerfIndexes()
root.sprocs = sprocsfrontend.SprocFrontend()
root.tables = tablesfrontend.TableFrontend()
cherrypy.quickstart(root, config=conf)
示例2: main
# 需要导入模块: import DataDB [as 别名]
# 或者: from DataDB import setConnectionString [as 别名]
def main():
parser = ArgumentParser(description = 'PGObserver Frontend')
parser.add_argument('-c', '--config', help = 'Path to config file. (default: %s)' % DEFAULT_CONF_FILE, dest="config" , default = DEFAULT_CONF_FILE)
args = parser.parse_args()
args.config = os.path.expanduser(args.config)
if not os.path.exists(args.config):
print 'Configuration file missing:', args.config
parser.print_help()
return
with open(args.config, 'rb') as fd:
settings = json.load(fd)
conn_string = ' '.join( ( "dbname=" + settings['database']['name'],
"host="+settings['database']['host'],
"user="+ settings['database']['frontend_user'],
"password="+ settings['database']['frontend_password'],
"port="+ str(settings['database']['port']) ) )
print "Setting connection string to ... " + conn_string
DataDB.setConnectionString ( conn_string )
if 'logfiles' in settings:
logdata.setFilter( settings['logfiles']['liveuserfilter'] )
current_dir = os.path.dirname(os.path.abspath(__file__))
conf = ( { 'global': { 'server.socket_host': '0.0.0.0',
'server.socket_port': int(settings['frontend']['port']) } ,
'/' : {'tools.staticdir.root' : current_dir },
'/static' : {'tools.staticdir.dir' : 'static' ,
'tools.staticdir.on' : True } } )
tplE.setup( settings )
root = None
for h in hosts.getHostData().values():
mf = MonitorFrontend.MonitorFrontend(h['host_id'])
if root == None:
root = mf
setattr(root , h['settings']['uiShortName'].lower().replace('-','') , mf)
root.report = report.Report()
root.sprocs = sprocsfrontend.SprocFrontend()
root.tables = tablesfrontend.TableFrontend()
cherrypy.quickstart(root,config=conf)
示例3: print
# 需要导入模块: import DataDB [as 别名]
# 或者: from DataDB import setConnectionString [as 别名]
try:
#print ('processing: {}', h)
conn = psycopg2.connect(host=h['host_name'], dbname=h['host_db'], user=h['host_user'], password=h['host_password'],connect_timeout='3')
cur = conn.cursor(cursor_factory=psycopg2.extras.RealDictCursor)
cur.execute(q_invalid, (h['host_name'], h['host_id']))
data_invalid += cur.fetchall()
cur.execute(q_unused, (h['host_name'], h['host_id'], indexing_thresholds['pit_min_size_to_report'], indexing_thresholds['pit_max_scans_to_report']))
data_unused += cur.fetchall()
cur.execute(q_duplicate, (h['host_name'], h['host_id']))
data_duplicate += cur.fetchall()
except Exception, e:
print ('ERROR could not connect to {}:{}'.format(h['host_name'], e))
data_noconnect.append({'host_id':h['host_id'],'host_name': h['host_name']})
finally:
if conn and not conn.closed:
conn.close()
data_invalid.sort(key=lambda x:x['index_size_bytes'],reverse=True)
data_unused.sort(key=lambda x:x['index_size_bytes'],reverse=True)
data_duplicate.sort(key=lambda x:x['table_size_bytes'],reverse=True)
return {'invalid':data_invalid, 'duplicate':data_duplicate, 'unused':data_unused, 'noconnect':data_noconnect}
if __name__ == '__main__':
DataDB.setConnectionString("dbname=dbmonitor host=localost user=postgres password=postgres")
#print (getTablePerformanceIssues('customer1.db.zalando',datetime.date(2013,8,23),datetime.date(2013,8,26)))
#print (getApiPerformanceIssues('stock2.db.zalando','r13_00_33','r13_00_34'))
#print (getIndexIssues('all'))
print (getIndexIssues('bm-master.db.zalando')['data_unused'])