DBI経由でPostgreSQLが動かないのでつまずいている経過報告

さて、DBD-PostgreSQLが導入できたところで、いよいよDBアクセス!!
当たり前だけど、ターゲットはPostgreSQLです。

参考は、http://www.gnu.org/software/smalltalk/manual/html_node/Database.html です。

ちなみに、上記ページのサンプルはそのままでは動きません。。。

connection := DBI.Connection
         connect: 'dbi:MySQL:dbname=test:host=localhost'
         user: 'doe'
         password: 'mypass').

<< connect: 'dbi:MySQL:dbname=test:host=localhost'
>> connect: 'dbi:MySQL:dbname=test;host=localhost' 
"「:」が「;」でないとか"

<< password: 'mypass').
>> password: 'mypass'. 
"「)」が不要とか。。。"

そもそもパッケージロードしないといけないんだよね。。。(結構ハマった。。orz)
で、作ったサンプルプログラム

" 複数ロードする場合 "
PackageLoader fileInPackages: #('DBI' 'DBD-PostgreSQL').
"
 単独の場合は
 PackageLoader fileInPackage: 'DBI'. とかで「fileInPackage(s)がいらない」
"

connect := DBI.Connection
           connect: 'DBI:PostgreSQL:dbname=test;host=localhost'
           user: 'postgres'
           password: nil.

connect inspect.

statement := connection execute: 'select * from t_test1;'.

実行すると。。。

gst db_sample.st

Loading package ROE
Loading package DBI
Loading package DBD-PostgreSQL
An instance of DBI.Connection class
  superClass: Object
  methodDictionary: MethodDictionary (
	#select:->DBI.Connection>>select:
	#primTableAt:ifAbsent:->DBI.Connection>>primTableAt:ifAbsent:
	#tableAt:->DBI.Connection>>tableAt:
	#close->DBI.Connection>>close
	#fieldConverter->DBI.Connection>>fieldConverter
	#>>->DBI.Connection>>>>
	#prepare:->DBI.Connection>>prepare:
	#database->DBI.Connection>>database
	#do:->DBI.Connection>>do:
	#tableAt:ifAbsent:->DBI.Connection>>tableAt:ifAbsent:
)
  instanceSpec: 4096
  subClasses: (DBI.PostgreSQL.PGConnection )
  instanceVariables: (#tables )
  name: #Connection
  comment: 'I represent a connection to a database.'
  category: 'DBI-Framework'
  environment: DBI
  classVariables: BindingDictionary (
	#Drivers->LookupTable (
	'PostgreSQL'->DBI.PostgreSQL.PGConnection
)
)
  sharedPools: ()
  securityPolicy: nil
  pragmaHandlers: nil
An instance of DBI.PostgreSQL.PGConnection
  tables: nil
  handle: DBI.PostgreSQL.PQConnection(16r1D4D030)
Object: nil error: did not understand #execute:
MessageNotUnderstood(Exception)>>signal (ExcHandling.st:254)
UndefinedObject(Object)>>doesNotUnderstand: #execute: (SysExcept.st:1407)
UndefinedObject>>executeStatements (db_access.st:15)

そもそも、なんで、connect inspectしてtablesがnilなのか。。。orz

まだまだ、時間がかかりそうです。。。