Skip to content

Instantly share code, notes, and snippets.

@masayuki5160
Created April 21, 2014 00:46
Show Gist options
  • Save masayuki5160/11129245 to your computer and use it in GitHub Desktop.
Save masayuki5160/11129245 to your computer and use it in GitHub Desktop.
PerlでSQLiteを使ってみる
use strict;
use warnings;
use DBI;
my $database = 'test.db';
my $data_src = "dbi:SQLite:dbname=$database";
my $dbh = DBI->connect($data_src);
my $createTableQuery = 'CREATE TABLE BOOK (title,author);';
$dbh->do($createTableQuery);
@masayuki5160
Copy link
Author

perldoc DBD::SQLite perldoc DBI
でモジュールが入っているかチェック.
ないときは以下で追加する.
cpan DBD::SQLite cpan DBI
dbファイルはこの設定だと実行ファイルと同じとこに作成された.
sqlite3 test.db
で接続して確認してみれば大丈夫.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment