ç´æçã« Users.create ãç¬ç«ãã¦ãããã«è¦ãã¦ãã©ã³ã¶ã¯ã·ã§ã³ç®¡çãããªãããã«æãããã ãã©ã ç´ ç´ã« transaction ã使ãã°ããã require 'rubygems' require 'sequel' # DB ãªã¼ãã³ DB = Sequel.sqlite("transaction.db") # ãã¼ãã«ãçæ unless DB.table_exists? :users DB.create_table :users do primary_key :id text :screen_name, :unique => true text :description end end # ã¢ãã«å®ç¾© class Users < Sequel::Model ; end # ãã¼ãã«ããã¬ã³ã¼ããåé¤ Users.delete # ã¬ã³ã¼ãã追å Users.create
Sequelã§ã¯has_manyã¨ãbelongs_toã¯ã¨ã¤ãªã¢ã¹ã§ãå®éã«ã¯one_to_many,many_to_one,many_to_manyã®3ã¤ã®ã¡ã½ããã ããåå¨ãã¾ããhas_oneç¸å½ã¯ããã¾ããã é¢ä¿ã®å®ç¾© ã ããããããªæãã class Article < Sequel::Model has_many :comments #è¤æ°ã®ã³ã¡ã³ããæã¤ã®ã§è¤æ°å½¢ belongs_to :category #ã²ã¨ã¤ã®ã«ãã´ãªã«æå±ããã®ã§åæ°å½¢ many_to_many :tags #è¤æ°ã®ã¿ã°ã¨ãã£ã¤ãã®ã§è¤æ°å½¢ end class Comment < Sequel::Model belongs_to :article end class Category < Sequel::Model has_many :articles end class Tag < Sequ
æãã¯è¨èã«ã ã¯ã¦ãªããã°ã¯ãããªãã®æããèããæ®ãããã ãã¾ãã¾ãªäººã綴ã£ãå¤æ§ãªä¾¡å¤è¦³ã«è§¦ãããã§ããå ´æã§ãã
ãã¥ã¼ããªã¢ã«ã¨ããã°æ²ç¤ºæ¿ã ã¨æãã®ã§æ²ç¤ºæ¿ãã¤ãã£ã¦ã¿ãã ã¤ã³ã¹ãã¼ã« gemã§ããããå ¥ãããaptã§SQLite3ã¨ããããã¨ãã # sudo gem install ramaze sequel erubis thin # ramaze -v Ramaze Version 2008.06, on ruby 1.8.6 (2007-09-24) [i486-linux] ããã¸ã§ã¯ãä½æ # ramaze --create bbs # cd bbs Model åããæ°ã«ãªã£ã¦ãSequelã使ããMerbãRailsã¿ããã«database.ymlã¨ããªãã®ã§çã§æ±ãã # vim model/post.rb require "sequel" DB=Sequel.sqlite "sqlite.db" class Post Time.now) if columns.include
Sequel is a lightweight database access toolkit for Ruby. Sequel provides thread safety, connection pooling and a concise DSL for constructing database queries and table schemas. Sequel also includes a lightweight but comprehensive ORM layer for mapping records to Ruby objects and handling associated records. Sequel supports advanced database features such as prepared statements, bound variables,
Objecttank@rubyã®DBã¢ã¯ã»ã¹ã©ã¤ãã©ãªãDBIããSequelã«ç§»è¡ä¸ãSequelã®åèãã¼ã¸http://sequel.rubyforge.org/http://www.slideshare.net/zhesto/ruby-off-rails-japanesehttp://xxx.mostevildanceclassics.com/page/r/SequelRubyã¤ã³ã¹ãã¼ã« sudo gem install sequel ã¨ããããå®è¡sequelã®ã³ãã³ãã©ã¤ã³ãã¼ã«ãrailsã®script/consoleã®ãããªãã®ã sequel mysql://user:password@localhost/dbname DBã¨ããååã®å¤æ°ã«æ¥ç¶ãªãã¸ã§ã¯ããæ ¼ç´ããããã¼ãã«å=userããã£ãã¨ããã¨ããã DB[:user].filter(:id => 10).a
ã¯ãã㫠第7åã¯Rails以å¤ã®Webãã¬ã¼ã ã¯ã¼ã¯ã®ç°¡åãªç´¹ä»ã¨ãSinatraã§Hello Worldã¢ããªã±ã¼ã·ã§ã³ãåããã¨ããã¾ã§ã解説ãã¾ãããä»åã¯Sinatraã§å®éã®ã¢ããªã±ã¼ã·ã§ã³ãä½ããSequelã¨Hamlã¨ãã2ã¤ã®ã©ã¤ãã©ãªãç´¹ä»ãã¾ãã Sinatraã®ç¹å¾´ã¯ãCGIã¹ã¯ãªããã®ããã«ãã¡ã¤ã«ä¸ã¤ããã¢ããªã±ã¼ã·ã§ã³ãæ¸ããæ°è»½ãã§ããCGIã¹ã¯ãªããã¨ããã°ã代表çãªãã®ã¯ä½ã¨è¨ã£ã¦ãæ²ç¤ºæ¿ï¼BBSï¼ã§ããããã§ãä»åã¯Sinatraã§æ²ç¤ºæ¿ã¢ããªãä½ã£ã¦ã¿ã¾ãããã½ã¼ã¹ã³ã¼ããå°ãé·ããªã®ã§ãgithubã«ã¦å ¨æãå ¬éãã¦ãã¾ããé©å®åç §ããªããèªã¿é²ãã¦ä¸ããããã¡ã¤ã«æ§æã¯ä»¥ä¸ã®ããã«ãªã£ã¦ãã¾ãã start.rb ã¢ããªã±ã¼ã·ã§ã³ã®æ¬ä½ã model/comment.rb æ²ç¤ºæ¿ã®æ¸ãè¾¼ã¿ã表ãã¢ãã«ã®å®ç¾©ã view/index.haml ãã
General Info, Guides, Examples, and Tutorials README Cheat Sheet Dataset Filtering Advanced Associations Prepared Statements/Bound Variables Master/Slave Databases and Sharding Schema Modification Full API RDoc, Main Classes/Modules: Sequel Sequel::Database Sequel::Dataset Sequel::Model Sequel::Model::Associations Sequel::Model::Associations::EagerLoading Change Log Release Notes License External
ãªãªã¼ã¹ãé害æ å ±ãªã©ã®ãµã¼ãã¹ã®ãç¥ãã
ææ°ã®äººæ°ã¨ã³ããªã¼ã®é ä¿¡
å¦çãå®è¡ä¸ã§ã
j次ã®ããã¯ãã¼ã¯
kåã®ããã¯ãã¼ã¯
lãã¨ã§èªã
eã³ã¡ã³ãä¸è¦§ãéã
oãã¼ã¸ãéã
{{#tags}}- {{label}}
{{/tags}}