Esempio n. 1
0
    def new(cls):
        instance = cls()
        instance._mysql_conn = MySql_Conn.new(setting.MYSQL_SETTING['host'],
                                              setting.MYSQL_SETTING[
                                                  'username'],
                                              setting.MYSQL_SETTING[
                                                  'password'],
                                              setting.MYSQL_SETTING['dbname'],
                                              setting.MYSQL_SETTING['port'])

        return instance
Esempio n. 2
0
def get_user_device_count(user_id):
    global user_device_count
    if user_id in user_device_count:
        return user_device_count[user_id]

    _device_db = MySql_Conn.new(
        "10.159.9.221", "push", "P@55word", "push", 3306)
    query_device_count = "select count(did) from device where uid=%s" % str(
        user_id)
    # print query_device_count
    try:
        device_count = _device_db.query_sql(query_device_count)[0][0]
    except Exception, e:
        device_count = 0
import json
import MySQLdb
from datetime import datetime, timedelta
import logging
from logging.handlers import RotatingFileHandler
from util_mysql import MySql_Conn
from util_common import get_table_name, get_date_str, get_yesterday
from util_log import logger
from util_html import get_provision_missmatch_table_str, get_image_tag
import setting

user_device_count = {}
result_table = {}

_db_conn_test = MySql_Conn.new(
    'localhost', 'root', '123456', 'dolphin_stat', 3306)

_db_conn = MySql_Conn.new(setting.MYSQL_SETTING['host'],
                          setting.MYSQL_SETTING['username'],
                          setting.MYSQL_SETTING['password'],
                          setting.MYSQL_SETTING['dbname'],
                          setting.MYSQL_SETTING['port'])


def get_provision_missmatch(date):
    date_str = get_date_str(date)
    table_name = get_table_name('Provision_locale', date)
    data_sql_str = "select country,count,miss_match from %s order by (miss_match/count) desc" % table_name
    datas = _db_conn.query_sql(data_sql_str)
    return datas
Esempio n. 4
0
import json
import MySQLdb
from datetime import datetime, timedelta
import logging
from logging.handlers import RotatingFileHandler
from util_mysql import MySql_Conn
from util_common import get_table_name, get_date_str, get_yesterday
from util_log import logger
from util_html import get_operation_nginx_table_str, get_image_tag
import setting

user_device_count = {}
result_table = {}

_db_conn_test = MySql_Conn.new("localhost", "root", "123456", "dolphin_stat", 3306)

_db_conn = MySql_Conn.new(
    setting.MYSQL_SETTING["host"],
    setting.MYSQL_SETTING["username"],
    setting.MYSQL_SETTING["password"],
    setting.MYSQL_SETTING["dbname"],
    setting.MYSQL_SETTING["port"],
)


def get_operation_nginx(date):
    date_str = get_date_str(date)
    table_name = get_table_name("DolphinOPService_nginx", date)
    data_sql_str = "select locale from %s where api_name='/api/2/provision.json'" % table_name
    datas = _db_conn.query_sql(data_sql_str)