Example #1
0
#coding=utf-8
import sys
import json
import os

sys.path.append("..")
from dbmanager import DbManager
from common import Common
os.chdir("../")

cfg = Common.loadConfig()
#print cfg['db']
db = DbManager()
db.initConn(cfg['db'])
sql = "show databases like 'cms_site_%'"
n,data = db.executeQuery(0,sql)
for row in data:
	pid = row[0].replace('cms_site_','')
	#创建statistics表
	sql = "CREATE TABLE IF NOT EXISTS `cms_template_statistics` (`template_id` int(11) NOT NULL COMMENT '模板id',`document_count` int(11) NOT NULL COMMENT '文档数',UNIQUE KEY `template_id` (`template_id`),KEY `document_count` (`document_count`)) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;"
	n,createdata = db.execute(pid,sql)
	print sql
	print '@@@@@@@@'
	sql = "show tables like 'cms_tbl_%'"
	n ,tbldata = db.executeQuery(pid,sql)
	for tbl in tbldata:
		tid = tbl[0].replace('cms_tbl_','')
		sql = 'select count(document_id) as doc_count from '+tbl[0]
		n,statdata = db.executeQuery(pid,sql)
		for stat in statdata:
			print 'TID:',tid,' Count:',stat[0]
Example #2
0
print(header_mail)
logging.info('DB:' + str(db_cfg))
cms_assert(db_cfg is None, 404, "can't find db cfg")
db = DbManager()
db.initConn([db_cfg])

pid = str(pid)
proj = Common.collection_find(project_cfg, lambda s: s['pid'] == int(pid))
cms_assert((proj is None and preview == 'N'), 404,
           "can't find publish domain,please check cfg")
domain = proj['domain']

# 获取模板信息
sql = "select `template_view`,`publish_callback`,`publish_url` from `cms_template` where `template_id`=" + str(
    tid)
n, data = db.executeQuery(pid, sql)

# 断言模板视图是否存在
cms_assert(n < 1, 404, "can't find template info")

template_view = data[0][0]
publish_url = data[0][2]

# 获取模板域信息
tbl_name = "cms_tbl_" + str(tid)
sql = "select `field_id`,`field_name`,`field_type`,`min_size`,`max_size`,`algorithm`,`default_value` from `cms_template_field` where `template_id`=" + str(
    tid) + " and `enable`=1 order by `display_order` asc"
field_count, data = db.executeQuery(pid, sql)

print('continue-3')
logging.info('[Compiler]:continue-3')