python sqlparse 各种 token
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的更多相关文章
- Python SyntaxError: invalid token
python命名不能以数字开头,import时会报错
- Python itsdangerous 生成token和验证token
代码如下 class AuthToken(object): # 用于处理token信息流程: # 1.更加给定的用户信息生成token # 2.保存生成的token,以便于后面验证 # 3.对用户请求 ...
- python接口自动化-token参数关联登录(二)
原文地址https://www.cnblogs.com/yoyoketang/p/9098096.html 原文地址https://www.cnblogs.com/yoyoketang/p/68866 ...
- python接口自动化-token参数关联登录(登录拉勾网)
前言 登录网站的时候,经常会遇到传token参数,token关联并不难,难的是找出服务器第一次返回token的值所在的位置,取出来后就可以动态关联了 登录拉勾网 1.先找到登录首页https://pa ...
- python Web生成token的几种方法,你确定不进来看看?
1.使用rest_framework_jwt from rest_framework_jwt.settings import api_settings jwt_payload_handler = ap ...
- python中使用token模拟登录
背景:在接口测试中我们经常是需要一个登陆token,或者获取其他用到的参数来关联下一个接口用到的参数. Token的意义及用法 一.Token的来源: 当客户端多次向服务端请求数据时,服务端就需要多次 ...
- python, Django csrf token的问题
环境 Window 7 Python2.7 Django1.4.1 sqlite3 问题 在使用Django搭建好测试环境后,写了一个提交POST表单提交留言的测试页面. 如图: 填写表单,点击“提交 ...
- openstack python sdk list tenants get token get servers
1,openstack python sdk 获取token 获取租户tenants projects #!/bin/bash export OS_PROJECT_DOMAIN_ID=default ...
- Python NLP入门教程
本文简要介绍Python自然语言处理(NLP),使用Python的NLTK库.NLTK是Python的自然语言处理工具包,在NLP领域中,最常使用的一个Python库. 什么是NLP? 简单来说,自然 ...
随机推荐
- [LeetCode&Python] Problem 257. Binary Tree Paths
Given a binary tree, return all root-to-leaf paths. Note: A leaf is a node with no children. Example ...
- [LeetCode&Python] Problem 458. Poor Pigs
There are 1000 buckets, one and only one of them contains poison, the rest are filled with water. Th ...
- HBuilder设置沉浸式状态栏显示效果
1:在[manifest.json]文件中,在[plus-->distribute--> apple]下加上[ "UIReserveStatusbarOffset":f ...
- Arduino SD卡 列出文件
/* SD卡测试 这个例子展示了如何使用实用程序库 sd库是基于获取您的SD卡的信息. 非常有用的测试卡,当你不确定它是否工作. 电路: *附在SPI总线上的SD卡如下: * MOSI引脚11上的Ar ...
- Docker的网络类型和固定IP设置
Docker的网络机制 Docker的网络有三种类型(driver): bridge, host 和 null. birdge: 就如同桥接的switch/hub, 使用bridge网络的contai ...
- awk命令过滤tomcat的访日日志中IP地址
1. 命令如下 批量过滤日志文件,grep -v是要排除10网段开头的IP地址 sort会自动按ip排序 uniq -c去重并计数 sort -n 按数值从小到大排序 [root@linux-node ...
- 记录一次mysql查询速度慢造成CPU使用率很高情况
1.某日zabbix告警,某台机器CPU使用率过高. 查看慢查询日志,看到很多sql语句都超过10秒 把sql语句拿出来放在查询窗口执行.前面加上explain就可以查看详细查询信息 playcode ...
- ubuntu18.04安装openresty
ubuntu18.04使用openresty官方APT源安装openresty 添加openresty的 APT 仓库,这样就可以便于未来安装或更新软件包(通过 apt-get update 命令). ...
- DNS主从配置详解
实验环境 主服务器:192.168.138.200 从服务器:192.168.138.201 bind安装 安装很简单,执行以下命令即可: yum install -y bind 先看一下bind的版 ...
- JS Replace 全部替换字符的用法小结
script language="javascript">var r= "1\n2\n3\n";//将字母\n替换成分号alert(r.replace(& ...