首页 技术 正文
技术 2022年11月11日
0 收藏 966 点赞 3,894 浏览 2100 个字

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

import sqlparsedef 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 Nonestring_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 语句 是一种tokenliststring_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开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,154
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,623
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,465
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,239
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,874
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:5,042