Skip to main content

Get the mysql's tokens by the tool.

Project description

mysqltokenparser

https://img.shields.io/pypi/v/mysqltokenparser.svg https://img.shields.io/travis/LoveXiaoLiu/mysqltokenparser.svg Documentation Status Updates

A awesome tool that easy to get MySQL’s tokens.

Quickstart

0x01 安装

pip install mysqltokenparser

0x02 使用教程

import mysqltokenparser as mtp

sql = u"""
    CREATE TABLE `aaa`.`t_zcm_operation_luck_award_record` (
      `id` bigint(20) NOT NULL,
      `operation_seq` varchar(30) NOT NULL,
      `award_user_id` bigint(20) NOT NULL,
      `award_type` int(11) DEFAULT NULL,
      `award_id` varchar(40) DEFAULT NULL UNIQUE KEY,
      `award_content` varchar(20)  DEFAULT NULL,
      `award_reason` varchar(30)  DEFAULT NULL,
      `award_source` int(11) DEFAULT NULL,
      `state` tinyint(4) NOT NULL PRIMARY KEY,
      `addtime` datetime NOT NULL,
      `updatetime` datetime NOT NULL,
      `ip` varchar(50)  DEFAULT NULL,
      `imei` varchar(50)  DEFAULT NULL,
      `intext` int(11) DEFAULT NULL,
      `longext` bigint(20) DEFAULT NULL,
      `strext` varchar(200)  DEFAULT NULL,
      PRIMARY KEY (id),
      UNIQUE KEY `idx_op_seq_uid_type` (`operation_seq`,`award_user_id`,`award_type`),
      KEY `idx_op_uid_type` (`award_user_id`,`award_type`),
      KEY `idx_op_uid_sss` (longext(10))
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
"""

token_obj = mtp.mysql_token_parser(sql)
tokens = token_obj.get_tokens()
print tokens
# {
#     'uniquekey': ['award_id'],
#     'columnnames': [u'id', u'operation_seq', u'award_user_id', u'award_type', u'award_id', u'award_content', u'award_reason', u'award_source', u'state', u'addtime', u'updatetime', u'ip', u'imei', u'intext', u'longext', u'strext'],
#     'tablenames': [u'aaa.t_zcm_operation_luck_award_record'],
#     'sqltype': ['ddl'],
#     'primarykey': ['state'],
#     'indexnames': [u'id', u'operation_seq,award_user_id,award_type', u'award_user_id,award_type', u'longext(10)']
# }

Features

  • TODO

Credits

This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.

History

0.1.0 (2019-07-08)

  • First release on PyPI.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mysqltokenparser-1.0.0.tar.gz (399.7 kB view hashes)

Uploaded Source

Built Distribution

mysqltokenparser-1.0.0-py2.py3-none-any.whl (405.1 kB view hashes)

Uploaded Python 2 Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page