Created
December 2, 2010 07:13
-
-
Save noqisofon/724923 to your computer and use it in GitHub Desktop.
Ruby の sqlite3 でテーブルを作成する。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!c:/bin/ruby/bin/ruby | |
# -*- encoding: shift_jis -*- | |
require 'rubygems' | |
require 'sqlite3' | |
# SQLite3 モジュールの取り込み。 | |
include SQLite3 | |
# データベースファイル作成。 | |
database = Database.new( "message-notifier.sqlite" ) | |
# テーブル作成のための SQL クエリ。 | |
sql_query = <<-SQL | |
create table messages ( | |
message_id int primary key, -- メッセージ番号。 | |
title varchar(128) not null, -- メッセージのタイトル。 | |
message varchar(1024) not null, -- メッセージ本文。 | |
creation_date datetime not null -- メッセージ作成日。 | |
) | |
SQL | |
puts sql_query | |
# クエリを実行。 | |
database.execute( sql_query ) | |
# データベースを閉じる。 | |
database.close |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment