Skip to content

Instantly share code, notes, and snippets.

View seanlook's full-sized avatar

xiaog seanlook

  • Tencent
  • ShenZhen
View GitHub Profile
@seanlook
seanlook / py
Created July 19, 2017 06:41
collect digests from proxysql periodically
#!/usr/local/bin/python2.7
"""
This script dump proxysql digest from `stats_mysql_query_digest` periodically but not too often.
In order to show the trends, difference is caculated to save to mysql table. Also print influxdb format.
`ProxySQL_Info` and `MySQL_Digest` should be given!
"""
import MySQLdb
import time
import sys
@seanlook
seanlook / sh
Created July 27, 2017 06:30
proxysql variables
mysql> show mysql variables;
+----------------------------------------+--------------------------------------+
| Variable_name | Value |
+----------------------------------------+--------------------------------------+
| mysql-client_found_rows | true |
| mysql-commands_stats | true |
| mysql-connect_retries_delay | 1 |
| mysql-connect_retries_on_failure | 10 |
| mysql-connect_timeout_server | 3000 |
| mysql-connect_timeout_server_max | 10000 |
@seanlook
seanlook / gen_navicat_conn.py
Created November 11, 2017 10:44
简单写了个脚本,根据Navicat导出的格式,生成EC目前在测试和开发环境所有MySQL实例的连接地址。 使用者只需要将当前目录下 connections.ncx 和 vgroup.xml 放到navicat适当目录下,即可获得所有地址信息,不需要再逐个手动添加
import pymysql
from collections import defaultdict
"""
This script is used to generate Navicat connections list to save your time adding many MySQL connection info to Navicat GUI.
output: (in current directory)
- connections.ncx: import it to navicat
- vgroup.xml: move it to navicat Profile location, usually C:\Users\ecuser\Documents\Navicat\Premium\profiles
{
"steps": [
{
"join_preparation": {
"select#": 1,
"steps": [
{
"expanded_query": "/* select#1 */ select `t_tbl_test_time_08`.`f_some_id` AS `f_some_id` from `t_tbl_test_time_08` where ((`t_tbl_test_time_08`.`f_qiye_id` = 5077665) and (`t_tbl_test_time_08`.`f_type` = 9) and (`t_tbl_test_time_08`.`f_contact_time` > '2017-10-17 14:23:49') and (`t_tbl_test_time_08`.`f_contact_time` < '2017-10-17 14:23:53')) order by `t_tbl_test_time_08`.`f_some_id` limit 300"
}
]
{
"steps": [
{
"join_preparation": {
"select#": 1,
"steps": [
{
"expanded_query": "/* select#1 */ select `t_tbl_test_time_08`.`f_some_id` AS `f_some_id` from `t_tbl_test_time_08` USE INDEX (`f_contact_time`) where ((`t_tbl_test_time_08`.`f_qiye_id` = 5077665) and (`t_tbl_test_time_08`.`f_type` = 9) and (`t_tbl_test_time_08`.`f_contact_time` > '2017-10-17 14:23:49') and (`t_tbl_test_time_08`.`f_contact_time` < '2017-10-17 14:23:53')) order by `t_tbl_test_time_08`.`f_some_id` limit 300"
}
]
{
"steps": [
{
"join_preparation": {
"select#": 1,
"steps": [
{
"expanded_query": "/* select#1 */ select `t_tbl_test_time_08`.`f_some_id` AS `f_some_id` from `t_tbl_test_time_08` where ((`t_tbl_test_time_08`.`f_qiye_id` = 5077665) and (`t_tbl_test_time_08`.`f_type` = 9) and (`t_tbl_test_time_08`.`f_contact_time` > '2017-10-17 14:23:49') and (`t_tbl_test_time_08`.`f_contact_time` < '2017-10-17 14:23:53')) order by `t_tbl_test_time_08`.`f_some_id` limit 8168"
}
]