Permalink
Browse files

Fixed behavior of error trap in sequel command line tool. Fixed metai…

…d dep in Rakefile.
  • Loading branch information...
1 parent 93f3a74 commit 92226c8c2f19416e483bf681170e6687678958df @ciconia ciconia committed Dec 30, 2007
Showing with 18 additions and 178 deletions.
  1. +5 −1 core/CHANGELOG
  2. +5 −175 core/README
  3. +7 −1 core/Rakefile
  4. +1 −1 core/bin/sequel
View
@@ -1,4 +1,8 @@
-=== 0.5 (2007-12-26)
+=== SVN
+
+* Fixed behavior of error trap in sequel command line tool.
+
+=== 0.5 (2007-12-30)
* Removed model code into separate sub-project. Rearranged trunk into core, model and model_plugins.
View
@@ -24,6 +24,10 @@ If you have any comments or suggestions please send an email to ciconia at gmail
sudo gem install sequel
+Note: as of version 0.5, Sequel models are distributed in a separate gem. In order to use sequel models, you should install the sequel_model gem:
+
+ sudo gem install sequel_model
+
== Supported Databases
Sequel currently supports:
@@ -74,178 +78,4 @@ Or getting results as a transposed hash, with one column as key and another as v
middle_east.to_hash(:name, :area) #=> {'Israel' => 20000, 'Greece' => 120000, ...}
-Much of Sequel is still undocumented (especially the part relating to model classes). The following section provides examples of common usage. Feel free to explore...
-
-== Getting Started
-
-=== Connecting to a database
-
-To connect to a database you simply provide Sequel with a URL:
-
- require 'sequel'
- DB = Sequel.open 'sqlite:///blog.db'
-
-The connection URL can also include such stuff as the user name and password:
-
- DB = Sequel.open 'postgres://cico:12345@localhost:5432/mydb'
-
-You can also specify optional parameters, such as the connection pool size, or a logger for logging SQL queries:
-
- DB = Sequel.open("postgres://postgres:postgres@localhost/my_db",
- :max_connections => 10, :logger => Logger.new('log/db.log'))
-
-=== Arbitrary SQL queries
-
- DB.execute("create table t (a text, b text)")
- DB.execute("insert into t values ('a', 'b')")
-
-Or more succinctly:
-
- DB << "create table t (a text, b text)"
- DB << "insert into t values ('a', 'b')"
-
-=== Getting Dataset Instances
-
-Dataset is the primary means through which records are retrieved and manipulated. You can create an blank dataset by using the dataset method:
-
- dataset = DB.dataset
-
-Or by using the from methods:
-
- posts = DB.from(:posts)
-
-You can also use the equivalent shorthand:
-
- posts = DB[:posts]
-
-Note: the dataset will only fetch records when you explicitly ask for them, as will be shown below. Datasets can be manipulated to filter through records, change record order and even join tables, as will also be shown below.
-
-=== Retrieving Records
-
-You can retrieve records by using the all method:
-
- posts.all
-
-The all method returns an array of hashes, where each hash corresponds to a record.
-
-You can also iterate through records one at a time:
-
- posts.each {|row| p row}
-
-Or perform more advanced stuff:
-
- posts.map(:id)
- posts.inject({}) {|h, r| h[r[:id]] = r[:name]}
-
-You can also retrieve the first record in a dataset:
-
- posts.first
-
-Or retrieve a single record with a specific value:
-
- posts[:id => 1]
-
-If the dataset is ordered, you can also ask for the last record:
-
- posts.order(:stamp).last
-
-=== Filtering Records
-
-The simplest way to filter records is to provide a hash of values to match:
-
- my_posts = posts.filter(:category => 'ruby', :author => 'david')
-
-You can also specify ranges:
-
- my_posts = posts.filter(:stamp => (2.weeks.ago)..(1.week.ago))
-
-Or lists of values:
-
- my_posts = posts.filter(:category => ['ruby', 'postgres', 'linux'])
-
-Sequel now also accepts expressions as closures, AKA block filters:
-
- my_posts = posts.filter {:category == ['ruby', 'postgres', 'linux']}
-
-Which also lets you do stuff like:
-
- my_posts = posts.filter {:stamp > 1.month.ago}
-
-Some adapters (like postgresql) will also let you specify Regexps:
-
- my_posts = posts.filter(:category => /ruby/i)
-
-You can also use an inverse filter:
-
- my_posts = posts.exclude(:category => /ruby/i)
-
-You can then retrieve the records by using any of the retrieval methods:
-
- my_posts.each {|row| p row}
-
-You can also specify a custom WHERE clause:
-
- posts.filter('(stamp < ?) AND (author <> ?)', 3.days.ago, author_name)
-
-Datasets can also be used as subqueries:
-
- DB[:items].filter('price > ?', DB[:items].select('AVG(price) + 100'))
-
-=== Summarizing Records
-
-Counting records is easy:
- posts.filter(:category => /ruby/i).count
-
-And you can also query maximum/minimum values:
- max_value = DB[:history].max(:value)
-
-Or calculate a sum:
- total = DB[:items].sum(:price)
-
-=== Ordering Records
-
- posts.order(:stamp)
-
-You can also specify descending order
-
- posts.order(:stamp.DESC)
-
-=== Deleting Records
-
- posts.filter('stamp < ?', 3.days.ago).delete
-
-=== Inserting Records
-
- posts.insert(:category => 'ruby', :author => 'david')
-
-Or alternatively:
-
- posts << {:category => 'ruby', :author => 'david'}
-
-=== Updating Records
-
- posts.filter('stamp < ?', 3.days.ago).update(:state => 'archived')
-
-=== Joining Tables
-
-Joining is very useful in a variety of scenarios, for example many-to-many relationships. With Sequel it's really easy:
-
- order_items = DB[:items].join(:order_items, :item_id => :id).
- filter(:order_items__order_id => 1234)
-
-This is equivalent to the SQL:
-
- SELECT * FROM items LEFT OUTER JOIN order_items
- ON order_items.item_id = items.id
- WHERE order_items.order_id = 1234
-
-You can then do anything you like with the dataset:
-
- order_total = order_items.sum(:price)
-
-Which is equivalent to the SQL:
-
- SELECT sum(price) FROM items LEFT OUTER JOIN order_items
- ON order_items.item_id = items.id
- WHERE order_items.order_id = 1234
-
+You can find more information on getting started with Sequel {here}[http://code.google.com/p/ruby-sequel/wiki/GettingStarted]
View
@@ -57,6 +57,8 @@ spec = Gem::Specification.new do |s|
s.executables = ["sequel"]
s.required_ruby_version = ">= 1.8.4"
+ s.add_dependency("metaid")
+
case RUBY_PLATFORM
when /mswin/
s.platform = Gem::Platform::CURRENT
@@ -67,7 +69,6 @@ spec = Gem::Specification.new do |s|
s.platform = "jruby"
else
s.platform = Gem::Platform::RUBY
- s.add_dependency("metaid")
# ParseTree on win32 requires PT2.1.1 and RI3.6.6
s.add_dependency("RubyInline", ">= 3.6.6")
s.add_dependency("ParseTree", ">= 2.1.1")
@@ -102,6 +103,11 @@ task :uninstall => [:clean] do
sh %{sudo gem uninstall #{NAME}}
end
+task :tag do
+ cwd = FileUtils.pwd
+ sh %{cd ../.. && svn copy #{cwd} tags/#{NAME}-#{VERS} && svn commit -m "#{NAME}-#{VERS} tag." tags}
+end
+
##############################################################################
# gem and rdoc release
##############################################################################
View
@@ -24,7 +24,7 @@ end
begin
DB = Sequel.connect db
rescue LoadError => e
- puts "Failed to load #{scheme} adapter: #{e.message}"
+ puts "Failed to load adapter: #{e.message}"
exit
rescue => e
puts e.message

0 comments on commit 92226c8

Please sign in to comment.