(图片来源网络,侵删)
最近在用这些个热热闹闹的AI做些工作上的辅助,其中一个是对csv内的SQL语句进行统计,写了下面一个要求:要求相对随意且重复,csv文件内,包含了几百条的SQL语句,现要对各个操作作统计,包含表的操作数量及次数做统计,需要体现SELECT查询了几次,UPDATE了几次,INSERT了几次等操作同时,还要分离出哪些表做了几次操作,比如XXX表查询了10次,UPDATE了10次,用python读取并生成结果同时,其中的SQL语句有大小写,都要能识别出来同时,还要按数量进行各自的排序同时,如果是FROM DUAL的概念,也要单独统计同时,各表的table operations count统计中,对各表的operations不只要统计数量,还要按操作类型统计同时,UPDATE和INSERT在后续的统计中,也要体现在各个表的操作统计内同时,如果一条记录的SQL语句内,涉及了多张表,也要把各表区分并统计如下面的SQL语句:SELECT t1.PSS_RELATION_ID, t1.XML_RMK FROM XX1 t0, X.XX2 t1 WHERE ((t0.POOL_PSS_REL_ID = ?) AND (t1.PSS_RELATION_ID = t0.TCF_PSS_REL_ID)),要统计出XX1 和X.XX2两张表,各自有一个SELECT操作要文件名为sql.csv类似的SQL语句如下:SELECT XX.XXX.NEXTVAL FROM DUALINSERT INTO XX.XXX (ID, BATCH, CREATE_DATE, PRJ_LEVEL, PSS_RELATION_ID, SORTING, TRANSPORT, UNLOAD) VALUES (?, ?, ?, ?, ?, ?, ?, ?)SELECT ID, DECO_PRD_PSS_ID, INQUIRY_ID, LATEST_VER_MARK, PREV_PSS_RELATION_ID, PSS_RELATION_ID FROM XX WHERE (INQUIRY_ID = ?)SELECT PSS_RELATION_ID, ADJUST_DAY, ALT_IDS, AVAILABLE, BANK_NO, CARS_NUM, COMMON_TYPE, CONFIRM_STATUS, CONTRACT_NO, COPY_SOURCE_EQUAL, COPY_SOURCE_ID, CREATE_DATE, CREATE_USER, DEFAULT_SET, DELIVERY_DATE, EFFECT_DATE, EXPIRE_DATE, FLOORS_NUM, FORMER_VERSION_ID, GZ_PSS_PROTYP, GZ_VER_GRP, JAP_PART, LATEST_AVAIBLE_VER_MARK, LATEST_VER_MARK, NS_MARK, NS_SIGN_MARK, PROJECT_NO, PROTYP, SMEC_PART, SPECIAL_TYPE, STATUS, SUPPLYER_CD, TECH_CONFIRM_NO, VER_GRP, VER_UPD_ID, VERSION_CODE, XML_RMK FROM XXX WHERE (PSS_RELATION_ID = ?)SELECT t1.PSS_RELATION_ID, t1.ALT_IDS, t1.BANK_NO, t1.CARS_NUM, t1.COMMON_TYPE, t1.CONFIRM_STATUS, t1.CONTRACT_NO, t1.CREATE_DATE, t1.CREATE_USER, t1.DEFAULT_SET, t1.DELIVERY_DATE, t1.EFFECT_DATE, t1.EXPIRE_DATE, t1.FLOORS_NUM, t1.GZ_PSS_PROTYP, t1.GZ_VER_GRP, t1.LATEST_AVAIBLE_VER_MARK, t1.LATEST_VER_MARK, t1.PREV_REL_ID, t1.PROJECT_NO, t1.PROTYP, t1.SOURCE_CFG_ID, t1.STATUS, t1.SUPPLYER_CD, t1.TCF_NO, t1.TCF_VERSION, t1.VER_GRP, t1.VERSION_CODE, t1.XML_RMK FROM XXX t0, XX.XX t1 WHERE ((t0.POOL_PSS_REL_ID = ?) AND (t1.PSS_RELATION_ID = t0.TCF_PSS_REL_ID))需要得到的统计格式类似:SQL Operations Count (Sorted by Count):SELECT: 1666UPDATE: 38INSERT: 23FROM DUAL:10Table Operations Count (Sorted by Total Operations):Table: XX1SELECT: 305UPDATE: 20INSERT: 3Table: XXXX2SELECT: 113INSERT: 3Table: XX.XX2SELECT: 100UPDATE: 2用的python包可包含:import csvimport refrom collections import Counter这么个要求,然后找了几个号称最牛的国内AI,搞了半天都没给出个能用的结果,各种傻瓜化:智谱AI勉强能出结果,但来回解释加说明也给不出完整的内容,一会数据纰漏一会统计不全,一会判断不对然后度度,写了几次也给不出结果,完全跑不起来之后只能用CHATGPT,直接给了两个完整的代码,差距还是很大智谱的至少跑跑起来了,只是统计不太全,这里不放了错误的是度给的答案跑出来的结果:(不知道度出的什么,可能和版本什么的还有关系?)另一个是GPT给的结果:chatgpt完全正确的结果百度的结果1百度的结果2
0 评论