今度は、SQLiteで試して見た。
ダウンロードサイトから、
Precompiled Binaries For Windows のところにある sqlite-shell-win32-x86-nnnnnn.zip
Precompiled Binaries For .NET の
System.Data.SQLite.org のリンク先から
sqlite-netFx35-binary-Win32-2008-n.n.n.n.zip をダウンロードして、適当なところに展開。
上はコマンドライン作業用で、下が .Net用のライブラリ。
.Net用はインストールされている.Net Frameworkにあわせてダウンロード。
私の環境では3.5が入っているので、3.5用を選択、展開先は
C:\Databases\SQLite\1.0.79.0で、先ずはDBを作成してテーブルをつくってデータを入れる。
PS C:\Databases\SQLite\1.0.79.0> .\sqlite3 sample.db
SQLite version 3.7.11 2012-03-20 11:35:50
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> create table test(col1 integer,col2 text,col3 text,col4 real,col5 text);
sqlite> .tables
test
sqlite> .schema
CREATE TABLE test(col1 integer,col2 text,col3 text,col4 real,col5 text);
sqlite> insert into test values (1,'あ','ア',3.14,'亜');
sqlite> insert into test values (2,'い','イ',3.14,'以');
sqlite> insert into test values (3,'う','ウ',3.14,'宇');
sqlite> insert into test values (4,'え','エ',3.1415,'江');
sqlite> insert into test values (5,'お','オ',3.141592,'才');
sqlite> select * from test;
1|あ|ア|3.14|亜
2|い|イ|3.14|以
3|う|ウ|3.14|宇
4|え|エ|3.1415|江
5|お|オ|3.141592|才
sqlite> .quit
PS C:\Databases\SQLite\1.0.79.0>
次にPowerShellでデータを取得するスクリプトを作成するけど、前につくったMySQL用とかの
Assemblyの指定や、接続用のクラスをSQLiteのものに変更するだけで動いた。
#---------------------------------------------------------------
[void][reflection.assembly]::LoadFrom("
C:\Databases\SQLite\1.0.79.0\System.Data.SQLite.dll")
$ConnectionString = "Data Source=
C:\Databases\SQLite\1.0.79.0\sample.db"
$sql = "select * from test"
$conn = New-Object
System.Data.SQLite.SQLiteConnection($ConnectionString)
#接続する
$conn.Open()
#SQLのセット
$command = New-Object
System.Data.SQLite.SQLiteCommand($sql, $conn)
#---------------------------------------------------------------
LoadFromのところは、インストーラ版をつかうと LoadWithPartialName をつかって
[void][reflection.assembly]::LoadWithPartialName ("System.Data.SQLite")のようなことが出来るかもしれない。