我尝试使用python库sqlparse从SQL语句中提取WHERE条件,并将其表示为条件JSON格式。我只对SQL条件感兴趣,所以起始点是一个虚拟的SQL语句,即select * from Table where Col1= 'aaa' AND Col2 > 10,它应该转换为如下所示的嵌套JSON格式: {"and&quo
想要解析sql join查询,选择sub查询成python。我使用的是sqlparse库。但我无法解析子查询。如何解析整个查询。"select id,fname,lname,address from res_users as r left join res_partner as p on p.id=r.partner_id wherename = (select name from res_partner where
我需要从一个SQL语句中提取所有被访问的表(具有不同类型的复杂性),但是我需要知道这个表来自哪个令牌,例如,如果有这样的查询: CREATE TABLE TABLE_B AS B SELECT * FROM))) WHERE (SELECT * FROM table_X LEFT JOIN TABLE.C ON atrb) 我的场景的预期输出将是: ['TABLE_B', 'TABLE_A']
如何使用Python从SQL查询字符串中提取列名及其条件,以便将结果映射到其他表并获得所需的数据?query = "SELECT COUNT(*) as cnt FROM dbo.main_table WHERE (VKRKA10001920015 = 1 AND age IN (15, 16, 17VKRKA10001920015': 1, 'income'
我正在寻找一些帮助,在多行但类似模式的字符串中搜索列表条件。每个子查询都有as (和),。因此,as space (和space ),模式。我想搜索每个模式中的子标准并生成一个输出。, var as var_1 from apple where code.. and code..qry_2 as ( select some from_code some code, wherevar as var_2 from pear where code.. and code..qry