X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;f=create-sql.lisp;h=3b8b39ca912589b131958be15331f42f7794bcae;hb=62ce365967f05ec6a2945a20cd5c45efb7b809e5;hp=4978843e5bb280230387844eab008ee9544f5f6d;hpb=188873f068b0c53febe4ee0ededbc755fce4869d;p=umlisp.git diff --git a/create-sql.lisp b/create-sql.lisp index 4978843..3b8b39c 100644 --- a/create-sql.lisp +++ b/create-sql.lisp @@ -38,8 +38,13 @@ (string-equal sqltype "CHAR")) (format nil "~a (~a)" sqltype (cmax c)) sqltype)))))) - (format nil "CREATE TABLE ~a (~{~a~^,~})" (table file) - (mapcar col-func (ucols file))))) + (format nil "CREATE TABLE ~a (~{~a~^,~})~A" + (table file) + (mapcar col-func (ucols file)) + (if (and (eq *umls-sql-type* :mysql) + (string-equal (table file) "MRCXT")) + " MAX_ROWS=200000000" + "")))) (defun create-custom-table-cmd (tablename sql-cmd) "Return SQL command to create a custom table" @@ -144,8 +149,36 @@ (dolist (file *umls-files*) (sql-execute (create-table-cmd file) conn))) +#+ignore +(defun sql-create-kcon-table (conn) + "Create concept table, one row per concept." + (ignore-errors (execute-command "DROP TABLE KCON" :database conn)) + (execute-command + (format nil "CREATE TABLE KCON (CUI INTEGER, STR ~A, LRL ~A)" + (case *umls-sql-type* + (:oracle + (format nil "VARCHAR2(~D)" + (slot-value (find-ucol "STR" "MRCONSO.RRF") 'max))) + (t "TEXT")) + (case *umls-sql-type* + (:mysql "TINYINT") + ((:postgresql :postgresql-socket) "INT2") + (:oracle "NUMBER(2,0)") + (t "INTEGER"))) + :database conn) + (dolist (tuple (query "select distinct cui from MRCONSO order by cui" + :database conn)) + (let ((cui (car tuple))) + (execute-command + (format nil "INSERT into KCON VALUES (~D,'~A',~D)" + cui + (add-sql-quotes (pfstr-hash cui) ) + (cui-lrl cui)) + :database conn)))) + (defun sql-create-custom-tables (conn) "SQL Databases: create all custom tables" + ;;(sql-create-kcon-table conn) (dolist (ct +custom-tables+) (sql-execute (create-custom-table-cmd (car ct) (cadr ct)) conn))) @@ -270,7 +303,7 @@ This is much faster that using create-umls-db-insert." "Return postgresql copy statement for a file" (format nil "COPY ~a FROM '~a' using delimiters '|' with null as ''" - (table file) (umls-pathname (fil file) extension))) + (table file) (ufile-pathname file extension))) (defun mysql-copy-cmd (file extension &key local-file) "Return mysql copy statement for a file" @@ -278,7 +311,7 @@ This is much faster that using create-umls-db-insert." nil "LOAD DATA ~AINFILE \"~a\" INTO TABLE ~a FIELDS TERMINATED BY \"|\"" (if local-file "LOCAL " "") - (umls-pathname (fil file) extension) (table file))) + (ufile-pathname file extension) (table file))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;