Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

解析sql 报字段不存在 #689

Open
yansdnfe opened this issue Nov 26, 2024 · 2 comments
Open

解析sql 报字段不存在 #689

yansdnfe opened this issue Nov 26, 2024 · 2 comments

Comments

@yansdnfe
Copy link

描述
select a.id,b.id from (select * from t1) a , t1 b where a.id=b.id
类似sql,同一个表的情况下,前一个表为子查询无法解析出a.id 字段

列 'a.id' 不存在.

重现
import pymysql

ince_dict={
"host":'127.0.0.1',
"port":4000
}

connect=pymysql.connect(**ince_dict)

cur=connect.cursor()

host="10.11.12.15"
user="archery"
port=3306
password="123456"

db_name="test3"
sql="select a.id,b.id from (select * from t1) a , t1 b where a.id=b.id;"
sql = f"""/--user={user};--password={password};--host={host};--port={port};--masking=1;/
inception_magic_start;
use {db_name};
{sql}
inception_magic_commit;"""

cur.execute(sql)

rows=cur.fetchall()

环境

  • 数据库: [mysql]
  • 版本: [例如 5.7.21]

参数
可能与问题相关的设置参数

@yansdnfe yansdnfe changed the title 解析不出字段 解析sql 报字段不存在 Nov 26, 2024
@zmix999
Copy link
Contributor

zmix999 commented Dec 18, 2024

select a.id,b.id from (select * from t1 c) a , t1 b where a.id=b.id 改成这样可以

@yansdnfe
Copy link
Author

select a.id,b.id from (select * from t1 c) a , t1 b where a.id=b.id 改成这样可以

通过改SQL可以解决,不过业务和开发用的时候,还是得花时间去排查问题或者修改尝试修改SQL,也是挺费劲的,最后通过判断是否可以成功解析,不能解析成功就直接放到数据库直接执行再对结果进行脱敏处理不判断具体字段归属了,感谢回复!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants