https://blog.csdn.net/qq_39607437/article/details/79620383

import sqlparse

def look(statement):
print("statement: {}".format(statement))
print("type: {}".format(type(statement)))
for token in statement:
print("{} ------ {} ----- {} ".format(type(token), token.ttype, token.value))
print("\n")
return None string_1 = "select * from history"
string_1_statement = sqlparse.parse(string_1)[0]
look(string_1_statement) string_2 = "select age from history where id = 10"
string_2_statement = sqlparse.parse(string_2)[0]
look(string_2_statement) string_3 = "select count(*) from history where age>10"
string_3_statment = sqlparse.parse(string_3)[0]
look(string_3_statment) string_4 = "select count(age) from history where age>10 and gender='women'"
string_4_statement = sqlparse.parse(string_4)[0]
look(string_4_statement) string_5 = "where id = 10"
string_5_statement = sqlparse.parse(string_5)[0]
look(string_5_statement)
print(string_5_statement.tokens)
print("\n")
look(string_5_statement[0])
look(string_5_statement[0][2]) string_6 = "where age >10 or gender != woman"
string_6_statement = sqlparse.parse(string_6)[0]
look(string_6_statement) # where 语句
look(string_6_statement[0]) # where 语句 是一种tokenlist string_7 = "age >10"
string_7_statement = sqlparse.parse(string_7)[0]
look(string_7_statement)
look(string_7_statement[0]) string_8 = "max(age)>10"
string_8_statement = sqlparse.parse(string_8)[0]
look(string_8_statement)
look(string_8_statement[0])
look(string_8_statement[0][0])
look(string_8_statement[0][0][1]) string_9 = "(age<10 or gender=man) and (age>18 and gender=10)"
string_9_statement = sqlparse.parse(string_9)[0]
look(string_9_statement)
look(string_9_statement[0]) string_10 = "select name as rs from applicant where zhima>557 limit 100, 100;"
string_10_statement = sqlparse.parse(string_10)[0]
look(string_10_statement) string_11 = "/* context_name=cut_age */ select count(*), gender from history where age>18 group by gender;"
string_11_statement = sqlparse.parse(string_11)[0]
look(string_11_statement) string_12 = "select age from applicant where applicant.name=tom"
string_12_statement = sqlparse.parse(string_12)[0]
look(string_12_statement) string_13 = "count(age)"
string_13_statement = sqlparse.parse(string_13)[0]
look(string_13_statement)
look(string_13_statement[0])

python sqlparse 各种 token的更多相关文章

  1. Python SyntaxError: invalid token

    python命名不能以数字开头,import时会报错

  2. Python itsdangerous 生成token和验证token

    代码如下 class AuthToken(object): # 用于处理token信息流程: # 1.更加给定的用户信息生成token # 2.保存生成的token,以便于后面验证 # 3.对用户请求 ...

  3. python接口自动化-token参数关联登录(二)

    原文地址https://www.cnblogs.com/yoyoketang/p/9098096.html 原文地址https://www.cnblogs.com/yoyoketang/p/68866 ...

  4. python接口自动化-token参数关联登录(登录拉勾网)

    前言 登录网站的时候,经常会遇到传token参数,token关联并不难,难的是找出服务器第一次返回token的值所在的位置,取出来后就可以动态关联了 登录拉勾网 1.先找到登录首页https://pa ...

  5. python Web生成token的几种方法,你确定不进来看看?

    1.使用rest_framework_jwt from rest_framework_jwt.settings import api_settings jwt_payload_handler = ap ...

  6. python中使用token模拟登录

    背景:在接口测试中我们经常是需要一个登陆token,或者获取其他用到的参数来关联下一个接口用到的参数. Token的意义及用法 一.Token的来源: 当客户端多次向服务端请求数据时,服务端就需要多次 ...

  7. python, Django csrf token的问题

    环境 Window 7 Python2.7 Django1.4.1 sqlite3 问题 在使用Django搭建好测试环境后,写了一个提交POST表单提交留言的测试页面. 如图: 填写表单,点击“提交 ...

  8. openstack python sdk list tenants get token get servers

    1,openstack python sdk 获取token 获取租户tenants projects #!/bin/bash export OS_PROJECT_DOMAIN_ID=default ...

  9. Python NLP入门教程

    本文简要介绍Python自然语言处理(NLP),使用Python的NLTK库.NLTK是Python的自然语言处理工具包,在NLP领域中,最常使用的一个Python库. 什么是NLP? 简单来说,自然 ...

随机推荐

  1. SQLI DUMB SERIES-8

    (1)在id后加单引号.无回显,加双引号跟正常输入是一样的回显,既然不会回显出错信息,只能进行盲注. (2)盲注的方法同less5

  2. Redis之在Linux上安装和简单的使用

    我只是一个搬运工 Redis之在Linux上安装和简单的使用https://blog.csdn.net/qq_20989105/article/details/76390367 一.安装gcc 1.R ...

  3. 绑定属性 - v-bind

    未绑定 <!DOCTYPE html><html><head>    <meta charset="utf-8">    <t ...

  4. node day2 vue read html

    app.js var http = require("http"); var fs = require('fs'); var url = require('url'); http. ...

  5. 1.1 VMware简介

    VMware是真正“同时”运行,多个操作系统在主系统的平台上,像标准Windows应用程序那样切换.而且每个操作系统你都可以进行虚拟的分区.配置而不影响真实硬盘的数据,通过网卡将几台虚拟机用网卡连接为 ...

  6. 第二章 C#语法基础(2.1 C#语言的数据类型一)

    C#的数据类型 [案例]本案例实现3位评委给一位选手评分,通过键盘输入各位评委的打分,通过屏幕输出该选手的平均分. [案例目的] (1)掌握变量的定义方式; (2)掌握常用的数据类型; (3)掌握数据 ...

  7. Hbase rowkey设计+布隆过滤器+STORE FILE & HFILE结构

    Rowkey设计 Rowkey设计原则 Rowkey设计应遵循以下原则: 1.Rowkey的唯一原则 必须在设计上保证其唯一性.由于在HBase中数据存储是Key-Value形式,若HBase中同一表 ...

  8. PostgreSQL Oracle 兼容性之 - sys_guid()

    Oracle 使用sys_guid()用来产生UUID值.  在PostgreSQL中有类似的函数,需要安装uuid-ossp插件.  如果用户不想修改代码,还是需要使用sys_guid()函数的话, ...

  9. 一个基于typelist的typemap

    前面的typelist的e一个小扩展,http://www.cnblogs.com/flytrace/p/3551414.html. 可以插入pair<key_type, value_type& ...

  10. Azure VMSS (2) 对VM执行Generalize操作

    <Windows Azure Platform 系列文章目录> 在本章中,笔者将介绍如何创建Azure Template镜像模板. 1.首先,我们先创建1台Windows Server 2 ...