本帖最后由 dcl1214 于 2024-4-9 12:48 编辑
有时前端页面还没有开发出来,或者是由于某种原因导致数据库的数据还没有录入,但是lisp开发不想等待,此时您可以快速模拟数据,便于lisp开展工作,我写了一个简单的快速入库的函数,代码如下
- (defun $db-mo-ren-shu-ju$ (tbn lst / info sql v-mr vs zds)
- ;往数据库写默认数据
- ;调用示例($mo-ren-shu-ju$ tbn-cpzk nil)
- (setq v-mr (list "甲子乙丑海中金" "丙寅丁卯炉中火"
- "戊辰己巳大林木" "庚午辛未路旁土"
- "壬申癸酉剑锋金" "甲戌乙亥山头火"
- "丙子丁丑涧下水" "戊寅己卯城头土"
- "庚辰辛巳白蜡金" "壬午癸未杨柳木"
- "甲申乙酉泉中水" "丙戌丁亥屋上土"
- "戊子己丑霹雳火" "庚寅辛卯松柏木"
- "壬辰癸巳长流水" "甲午乙未沙中金"
- "丙申丁酉山下火" "戊戌己亥平地木"
- "庚子辛丑壁上土" "壬寅癸卯金箔金"
- "甲辰乙巳覆灯火" "丙午丁未天河水"
- "戊申己酉大驿土" "庚戌辛亥钗钏金"
- "壬子癸丑桑柘木" "甲寅乙卯大溪水"
- "丙辰丁巳沙中土" "戊午己未天上火"
- "庚申辛酉石榴木" "壬戌癸亥大海水"
- "乾" "坤" "屯"
- "蒙" "需" "讼"
- "师" "比" "小畜"
- "履" "泰" "否"
- "同人" "大有" "谦"
- "豫" "随" "蛊"
- "临" "观" "噬嗑"
- "贲" "剥" "复"
- "无妄" "大畜" "颐"
- "大过" "坎" "离"
- "咸" "恒" "遁"
- "大壮" "晋" "明夷"
- "家人" "睽" "蹇"
- "解" "损" "益"
- "夬" "姤" "萃"
- "升" "困" "井"
- "革" "鼎" "震"
- "艮" "渐" "归妹"
- "丰" "旅" "巽"
- "兑" "涣" "节"
- "中孚" "小过" "既济"
- "未济" "青龙" "白虎"
- "朱雀" "玄武" "太阳烛照"
- "太阴幽荧" "应龙" "螣蛇"
- "勾陈" "白泽" "麒麟"
- "凤凰" "水麒麟" "赤焰兽"
- "獬豸"
- )
- )
- (setq info ($cha-xun-biao-xin$ tbn))
- (setq
- zds
- (mapcar
- (function
- (lambda (a / typ)
- (OR (setq typ (cdr (assoc "DATA_TYPE" a)))
- (setq typ (cdr (assoc "TYPE" a)))
- )
- (IF
- (AND
- TYP
- (WCMATCH
- (STRCASE TYP)
- "[,*VARCHAR*,*STRING*,STRING,*TEXT*,TEXT,CHAR,ENUM,TINYTEXT,LONGTEXT,MEDIUMTEXT,]"
- )
- )
- (cdr (assoc "COLUMN_NAME" a))
- )
- )
- )
- info
- )
- )
- (SETQ zds (VL-REMOVE NIL zds))
- (setq zds (vl-remove-if
- (function
- (lambda (a) (member a (list "id" "ID" "UID" "uid")))
- )
- zds
- )
- )
- (if (and zds
- v-mr
- (setq vs (mapcar 'cons zds v-mr))
- (setq sql (strcat "insert into "
- tbn
- "("
- (merge-str-by-bar (mapcar 'car vs) ",")
- ")values('"
- (merge-str-by-bar (mapcar 'cdr vs) "','")
- "')"
- )
- )
- )
- ($http-server$
- (list
- (cons "IP" (getenv "数据库地址"))
- (cons "端口" ($locport$))
- (cons "接口" ($fu-wu-qi-jie-kou$ "修改表数据"))
- ;(cons "数据库路径" "C:\\ZXCAD.DB")
- (cons "报文头"
- (list (cons "Client-Auth" (getenv "ComputerName")))
- )
- (cons "Sql" sql)
- (cons "http方法" "POST")
- (cons "返回格式" "str")
- )
- )
- )
- )
|