我正在研究OS X 10.6.4.我一直在使用clbuild为SBCL安装支持库(包括clsql),我通过Aquamacs完成所有工作.我使用Hive Logic上的优秀指令安装了MySQL .但是,当我调用(require 'clsql)- 这似乎工作正常 - 然后尝试执行(clsql:connect '(nil "lisp" "root" "") :database-type :mysql)连接到我的本地运行数据库时,我收到此错误消息:
erred while invoking #<COMPILE-OP (:VERBOSE NIL) {12096109}> on
#<CLSQL-MYSQL-SOURCE-FILE "clsql_mysql" {1208E071}>
[Condition of type ASDF:OPERATION-ERROR]
Run Code Online (Sandbox Code Playgroud)
从我对这个问题的研究中,我认为它来自我没有libmysqlclient.dylib文件的编译版本,我在/ usr/local/mysql/lib /中有一个副本,但我不清楚如何去编译它.这个论坛帖似乎说我正是我需要做的,但该目录中没有make文件.
我正在尝试使用clsql:select函数创建子查询:
CL-USER> (select [books.bookid]
:from [books]
:where
(sql-in [books.bookid]
(select [bookid]
:from [bookauthors]
:where
(sql-= [bookauthors.authorid] 120))))
;; 2015-03-07T06:37:08 /books/ => SELECT BOOKID FROM BOOKAUTHORS WHERE (BOOKAUTHORS.AUTHORID = 120)
;; 2015-03-07T06:37:08 /books/ => SELECT BOOKS.BOOKID FROM BOOKS WHERE (BOOKS.BOOKID IN ((157)))
((157))
("bookid")
Run Code Online (Sandbox Code Playgroud)
它可以工作,但是clsql运行两个查询,而不是使用sub-select子句生成一个查询.这不会像让postgresql后端处理整个事情那样高效.
CL-USER> (clsql-sys:db-type-has-subqueries? :postgresql)
T
Run Code Online (Sandbox Code Playgroud)
显然postgresql连接器支持子查询.有没有办法让select函数生成它们?
在Windows10/64上,我安装了CCL Lisp 1.11,下载了sqlite3.dll,然后安装了quicklisp和cl-sql.我在(德语)特殊字符的上下文中出错.这是我在Emacs Slime Repl中尝试过的:
(clsql:connect '("C:/users/user/test.sqlite")
:database-type :sqlite3
:encoding 'utf-8)
(clsql:execute-command "create table name (name)")
(clsql:execute-command "insert into name values ('Übermaß')")
(format t "~A" (clsql:query "select * from name") )
Run Code Online (Sandbox Code Playgroud)
执行最后一行调用调试器:
Cannot allocate a STRING with NIL elements.
Objects of type STRING can can have at most
16777215 elements in this implementation.
[Condition of type CCL::VECTOR-SIZE-LIMITATION] ...
Backtrace
0: (%STR-FROM-PTR #<A Foreign Pointer #x2D0F8C8> NIL NIL)
1: ((:INTERNAL CLSQL-SQLITE3::EXTRACT-ROW-DATA (CLSQL-SYS:DATABASE-QUERY (T CLSQL-SQLITE3:SQLITE3-DATABASE T T))))
2: (#<STANDARD-METHOD CLSQL-SYS:DATABASE-QUERY (T CLSQL-SQLITE3:SQLITE3-DATABASE …Run Code Online (Sandbox Code Playgroud) 我在运行10.5.8的英特尔酷睿2双核Macbook上安装了SBCL(通过macports/darwinports).我安装了几个像这样的库:
(require 'asdf)
(require 'asdf-install)
(asdf-install:install 'cl-who)
Run Code Online (Sandbox Code Playgroud)
但是当我'clsql下载后尝试以这种方式安装CLSQL时,我得到了这个:
...
; registering #<SYSTEM CLSQL-UFFI {123D9E01}> as CLSQL-UFFI
; $ cd /Users/ken/.sbcl/site/clsql-5.0.5/uffi/; make
cc -arch x86_64 -arch i386 -bundle /usr/lib/bundle1.o -flat_namespace -undefined suppress clsql_uffi.c -o clsql_uffi.dylib
ld: duplicate symbol dyld_stub_binding_helper in /usr/lib/bundle1.o and /usr/lib/bundle1.o for architecture i386
ld: duplicate symbol dyld_stub_binding_helper in /usr/lib/bundle1.o and /usr/lib/bundle1.o for architecture x86_64
collect2: ld returned 1 exit status
collect2: ld returned 1 exit status
lipo: can't open input file: /var/folders/Nf/Nf4o5ArDFaWBH2OwtnWM3E+++TQ/-Tmp-//ccJyZxou.out (No such file or …Run Code Online (Sandbox Code Playgroud) 我想使用clsql的sqlite3接口.我已经使用quicklisp 安装了.但是当我尝试运行时:clsql
(clsql:with-database (db '("database.db")
:database-type :sqlite3)
nil)
Run Code Online (Sandbox Code Playgroud)
我明白了
OPERATION-ERROR while invoking #<COMPILE-OP > on
#<CLSQL-UFFI-SOURCE-FILE "clsql-uffi" "uffi" "clsql_uffi">
[Condition of type ASDF/BACKWARD-INTERFACE:OPERATION-ERROR]
Run Code Online (Sandbox Code Playgroud)
如果我只是试着赶紧行动,那就是一样的clsql-uffi.
cl-sql,cl-sql-uffi,cl-sql-sqlite3和libsqlite3-dev安装.我正在使用Ubuntu,Linux.
在Common Lisp中,如何定义一个"元宏",它将宏(和其他参数)列表作为参数,并组合这些宏以生成所需的代码.
这个问题等同于编写一个"高阶宏",它定义了其他宏的变量列表中的宏.
提示问题的具体情况是我对CLSQL的实验,我想从CLSQL-testsuite重新表达员工类
(clsql:def-view-class employee ()
((employee-id
:db-kind :key
:db-constraints (:not-null)
:type integer)
(first-name
:accessor employee-first-name
:type (string 30)
:initarg :first-name)
(last-name
:accessor employee-last-name
:type (string 30)
:initarg :last-name)
(email
:accessor employee-email
:type (string 100)
:initarg :email)
(company-id
:type integer
:initarg :company-id)
(company
:accessor employee-company
:db-kind :join
:db-info (:join-class company
:home-key companyid
:foreign-key companyid
:set nil))
(manager-id
:type integer
:nulls-ok t
:initarg :manager-id)
(manager
:accessor employee-manager
:db-kind :join
:db-info (:join-class employee
:home-key managerid
:foreign-key emplid
:set nil))))
Run Code Online (Sandbox Code Playgroud)
如
(def-view-class-with-traits …Run Code Online (Sandbox Code Playgroud) 我想创建一个新的sqlite3数据库.看一下clsql的例子,我发现了这个场景.这意味着
(ql:quickload "clsql")
(ql:quickload "clsql-sqlite3")
(uffi:def-function
("create_iso_8859_15_ci_collation" create-coll)
((db sqlite3:sqlite3-db))
:returning :int
:module "sqlite3-utils")
(clsql:connect (list "home/user/test.db" #'create-coll) :database-type :sqlite3)
Run Code Online (Sandbox Code Playgroud)
应该创建一个新的数据库.但相反,我得到:
外来函数"create_iso_8859_15_ci_collation"未定义.[SB-KERNEL类型的条件::未定 - 异常 - 错误 - 错误]
如何从头开始创建新的sqlite3数据库?
clsql ×7
common-lisp ×7
sqlite ×3
lisp ×2
sbcl ×2
ccl ×1
libmysql ×1
lisp-macros ×1
macos ×1
mysql ×1
postgresql ×1
quicklisp ×1