kikuchi
Gauche-dbd-sqlite3 0.1.3 (2008/05/22 02:35:20 PDT)
http://autogol.ath.cx/dbd-sqlite3/Gauche-dbd-sqlite3-0.1.3.tgz
変更点
- インストール時の不具合を修正(Debianでしか確認していなかった。多分Cygwinにも対応)
- ドキュメント書き始めたけど、まだかなり半端
Gauche-dbd-sqlite3 0.1.2 (2008/04/29 11:58:12 PDT)
http://autogol.ath.cx/dbd-sqlite3/Gauche-dbd-sqlite3-0.1.2.tgz
変更点
- SQLite3を同梱するのをやめた。(pkg-configが必須。SQLite3.5.1以降に対応)
- dbd.sqlite3.baseモジュールをsqlite3に変更。
- エラー検出を改善。
- dbi-funcを変更。<sqlite3-connect>に対して使うと<sqlite3-db>を第一引数に持ってきたり。
- sqlite3-create-function*、sqlite3-create-aggregate*を追加。
(use dbi) (use util.relation) (define conn (dbi-connect "dbi:sqlite3:db=:memory:")) (dbi-func conn 'sqlite3-create-function* "my_func" -1 5 +) (print (relation-rows (dbi-do conn "select my_func(1, 2, 3)")))
あと今更ですが、cise使っているので、新しめのGaucheでないと動きません。
dbd-sqlite3を更新しました。(2008/04/18 12:42:59 PDT)
http://autogol.ath.cx/dbd-sqlite3/Gauche-dbd-sqlite3-0.1.1.tgz
変更点は以下です。
- 同梱のSQLite3を3.5.8に更新。
- 同梱のSQLite3を使わずにlibsqlite3.soを利用可能になりました。
$ tar zxvf Gauche-dbd-sqlite3-0.1.1.tgz $ cd Gauche-dbd-sqlite3-0.1.1 $ cp shared/* . $ aclocal $ autoconf $ ./configure $ make $ make check $ sudo make install
- <sqlite3-query>を閉じ忘れても、<sqlite3-connection>を閉じられるようにしました。
- dbi-executeとdbi-doでリレーションを返さないとき、変更された行数を返すようにした。
- Perl DBIのfuncみたいに(dbi-func <dbi-connection> <symbol> . args)を作ってみた。
関数作成をdbi-funcを使って書き直してみたが、正直微妙。タイプ量は増えるし、定数は参照できないし。(use dbi) (use dbd.sqlite3) ; dbi-func (define conn (dbi-connect "dbi:sqlite3:db=:memory:")) (define db (slot-ref conn 'db)) (define (my-func context . args) (dbi-func conn 'sqlite3-result-int context (apply + (map (cut dbi-func conn 'sqlite3-value-int <>) args)))) (dbi-func conn 'sqlite3-create-function db "my_func" -1 5 my-func)
何番煎じかわかりませんが、sqlite3のモジュールを作ってみました。
http://autogol.ath.cx/Gauche-dbd-sqlite3-0.1.tgz
一応特徴としては、
- sqlite3のソース入り
- libsqlite3を大体ラップ済み(↓みたいな感じで関数を追加できたり)
(use dbi) (use dbd.sqlite3.base) (use util.relation) (use srfi-1) (define conn (dbi-connect "dbi:sqlite3:db=:memory:")) (define db (slot-ref conn 'db)) (define (my-func context . args) (sqlite3-result-int context (apply + (map sqlite3-value-int args)))) (sqlite3-create-function db "my_func" -1 SQLITE_ANY my-func) (let1 res (dbi-do conn "select my_func(1, 2, 3, 4)") (print (relation-rows res))) (define (my-step context x) (sqlite3-set-aggregate-context context (+ (sqlite3-value-int x) (sqlite3-get-aggregate-context context 0)))) (define (my-final context) (sqlite3-result-int context (sqlite3-get-aggregate-context context 0))) (sqlite3-create-aggregate db "my_agg" 1 SQLITE_ANY my-step my-final) (dbi-do conn "create table test (a integer)") (let loop ([lst (iota 10)]) (unless (null? lst) (dbi-do conn "insert into test values (?)" '() (car lst)) (loop (cdr lst)))) (let1 res (dbi-do conn "select my_agg(a) from test") (print (relation-rows res))) (dbi-close conn) 0
- 例外処理があやしい orz
yuumi3(http://d.hatena.ne.jp/yuum3/ )です、変更ありがとうございます。Mac OS/X はOKでした。 しかし cygwinでは以下のようなエラーになりました。
bash-3.2$ ./configure checking build system type... i686-pc-cygwin checking host system type... i686-pc-cygwin checking target system type... i686-pc-cygwin checking for gosh... /usr/local/bin/gosh checking for gauche-config... /usr/local/bin/gauche-config checking for gauche-package... /usr/local/bin/gauche-package checking for gauche-install... /usr/local/bin/gauche-install checking for gauche-cesconv... /usr/local/bin/gauche-cesconv checking for pkg-config... /usr/bin/pkg-config checking pkg-config is at least version 0.9.0... yes checking for SQLITE3... yes checking for gcc... gcc checking for C compiler default output file name... a.exe checking whether the C compiler works... yes checking whether we are cross compiling... no checking for suffix of executables... .exe checking for suffix of object files... o checking whether we are using the GNU C compiler... yes checking whether gcc accepts -g... yes checking for gcc option to accept ISO C89... none needed checking for sqlite3_table_column_metadata... no checking for sqlite3_load_extension... no checking for sqlite3_set_authorizer... yes checking for sqlite3_complete... yes checking for sqlite3_progress_handler... yes checking for sqlite3_enable_shared_cache... yes checking for sqlite3_trace... yes checking for sqlite3_blob_open... yes checking for sqlite3_column_decltype... yes configure: creating Gauche-dbd-sqlite3.gpd configure: creating ./config.status config.status: creating Makefile bash-3.2$ make /usr/local/bin/gauche-package compile --verbose --cflags="" --cppflags="-DSQLITE _OMIT_LOAD_EXTENSION=1 -DGAUCHE_API_0_9" --ldflags="" --libs="-lsqlite3 /usr/l ocal/lib/gauche/0.8.13/i686-pc-cygwin/libgauche-uvector.dll" sqlite3 ./sqlite3.c ./sqlite3lib.stub '/usr/local/lib/gauche/0.8.13/i686-pc-cygwin/gauche-config' --fixup-extension 's qlite3' gcc -std=gnu99 -c -DSQLITE_OMIT_LOAD_EXTENSION=1 -DGAUCHE_API_0_9 -I/usr/local/l ib/gauche/0.8.13/include -o 'sqlite3_head.o' 'sqlite3_head.c' gcc -std=gnu99 -c -DSQLITE_OMIT_LOAD_EXTENSION=1 -DGAUCHE_API_0_9 -I/usr/local/l ib/gauche/0.8.13/include -o 'sqlite3.o' './sqlite3.c' '/usr/local/lib/gauche/0.8.13/i686-pc-cygwin/gosh' genstub ./sqlite3lib.stub gcc -std=gnu99 -c -DSQLITE_OMIT_LOAD_EXTENSION=1 -DGAUCHE_API_0_9 -I/usr/local/l ib/gauche/0.8.13/include -o 'sqlite3lib.o' './sqlite3lib.c' gcc -std=gnu99 -c -DSQLITE_OMIT_LOAD_EXTENSION=1 -DGAUCHE_API_0_9 -I/usr/local/l ib/gauche/0.8.13/include -o 'sqlite3_tail.o' 'sqlite3_tail.c' gcc -std=gnu99 -L/usr/local/lib/gauche/0.8.13/i686-pc-cygwin -Wl,--export-all- symbols -Wl,--enable-auto-import -shared -o sqlite3.dll 'sqlite3_head.o' 'sqlite 3.o' 'sqlite3lib.o' 'sqlite3_tail.o' -lgauche -lm -lpthread -lsqlite3 /usr/lo cal/lib/gauche/0.8.13/i686-pc-cygwin/libgauche-uvector.dll sqlite3lib.o:sqlite3lib.c:(.text+0x49a5): undefined reference to `_sqlite3_limit ' sqlite3lib.o:sqlite3lib.c:(.text+0x5415): undefined reference to `_sqlite3_rando mness' sqlite3lib.o:sqlite3lib.c:(.text+0x58a5): undefined reference to `_sqlite3_resul t_error_code' sqlite3lib.o:sqlite3lib.c:(.text+0x6636): undefined reference to `_sqlite3_sql' collect2: ld returned 1 exit status *** ERROR: command execution failed: gcc -std=gnu99 -L/usr/local/lib/gauche/0.8 .13/i686-pc-cygwin -Wl,--export-all-symbols -Wl,--enable-auto-import -shared -o sqlite3.dll 'sqlite3_head.o' 'sqlite3.o' 'sqlite3lib.o' 'sqlite3_tail.o' -lgauc he -lm -lpthread -lsqlite3 /usr/local/lib/gauche/0.8.13/i686-pc-cygwin/libgau che-uvector.dll Stack Trace: _______________________________________ 0 args 1 (usage) At line 99 of "(input string port)" make: *** [sqlite3.dll] Error 70