aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib
diff options
context:
space:
mode:
authorRalph Amissah <ralph@amissah.com>2014-05-18 08:57:10 -0400
committerRalph Amissah <ralph@amissah.com>2014-05-18 08:57:12 -0400
commitbcb074af136731ff36e479090447f21dd13aa218 (patch)
tree88b10f717b80c789e5a5063b57a1f68168e37f90 /lib
parentv5 v6: db, remove ruby-dbi, for: pg ruby-pg, sqlite ruby-sqlite3 (already uses) (diff)
v5 v6: cgi, sample search forms: use ruby-pg & ruby-sqlite3; remove ruby-dbisisu_5.3.6
Diffstat (limited to 'lib')
-rw-r--r--lib/sisu/v5/cgi_pgsql.rb22
-rw-r--r--lib/sisu/v5/cgi_sqlite.rb12
-rw-r--r--lib/sisu/v5/sysenv.rb2
-rw-r--r--lib/sisu/v6/cgi_pgsql.rb29
-rw-r--r--lib/sisu/v6/cgi_sqlite.rb12
-rw-r--r--lib/sisu/v6/sysenv.rb2
6 files changed, 33 insertions, 46 deletions
diff --git a/lib/sisu/v5/cgi_pgsql.rb b/lib/sisu/v5/cgi_pgsql.rb
index 53c73c8d..6c4385e4 100644
--- a/lib/sisu/v5/cgi_pgsql.rb
+++ b/lib/sisu/v5/cgi_pgsql.rb
@@ -128,12 +128,9 @@ module SiSU_CGI_PgSQL
default database name: #{@cX.green}#{Db[:name_prefix]}#{@name_of[:db]}#{@cX.off} (#{@name_of[:db]})
db user: #{@cX.green}#{@name_of[:user]}#{@cX.off}
to modify use: #{@cX.brown}sisu --db-pg --db-user='#{@name_of[:user]}'#{@cX.off}
- cgi & db host on: #{@cX.blue}#{@name_of[:host_url_cgi]}#{@cX.off}
- to modify use: #{@cX.brown}sisu --db-pg --webserv-search='#{@name_of[:host_url_cgi]}'#{@cX.off}
- sisu output on: #{@cX.blue}#{@name_of[:host_url_docs]}#{@cX.off}
- to modify use: #{@cX.brown}sisu --db-pg --webserv-output='#{@name_of[:host_url_docs]}'#{@cX.off}
- cgi search form link name: #{@cX.green}#{@name_of[:cgi_script]}#{@cX.off}
- to modify use: #{@cX.brown}sisu --db-pg --cgi-search-form-name='#{@name_of[:cgi_script]}'#{@cX.off}
+ to create static cgi & db host use: #{@cX.brown}sisu --db-pg --webserv-search='#{@name_of[:host_url_cgi]}'#{@cX.off}
+ for static location for sisu output use: #{@cX.brown}sisu --db-pg --webserv-output='#{@name_of[:host_url_docs]}'#{@cX.off}
+ for static cgi search form link name use: #{@cX.brown}sisu --db-pg --cgi-search-form-name='#{@name_of[:cgi_script]}'#{@cX.off}
#{@cX.fuchsia}(settings priority: command line; sisurc.yml; else defaults)#{@cX.off}
#{@cX.fuchsia}BASED ON ALREADY EXISTING databases#{@cX.off} (default database name: #{@db.psql.db})
@@ -151,7 +148,7 @@ module SiSU_CGI_PgSQL
#{@cX.brown}createdb #{@db.psql.db}#{@cX.off}
[for a list of existing databases try 'psql --list']"
- now you can use sisu to create the database tables and populate the database with documents
+ you can use sisu to create the database tables and populate the database with documents
sisu --pg --dropall # removes existing postgresql db & tables
sisu --pg --createall -v # creates postgresql db & tables
@@ -195,9 +192,9 @@ module SiSU_CGI_PgSQL
begin
require 'cgi'
require 'fcgi'
- require 'dbi'
+ require 'pg'
rescue LoadError
- puts 'cgi, fcgi or dbi NOT FOUND (LoadError)'
+ puts 'cgi, fcgi or pg NOT FOUND (LoadError)'
end
@stub_default='#{@name_of[:db]}'
@image_src="#{@image_src}"
@@ -277,10 +274,10 @@ module SiSU_CGI_PgSQL
%{<font color="#666666" size="2">#{sql_select_endnotes}</font>}
end
def contents
- @conn.select_all(sql_select_body)
+ @conn.exec(sql_select_body)
end
def endnotes
- @conn.select_all(sql_select_endnotes)
+ @conn.exec(sql_select_endnotes)
end
end
WOK_SQL
@@ -292,8 +289,7 @@ module SiSU_CGI_PgSQL
end
def dbi_connect
<<-'WOK_SQL'
- dbi="dbi:Pg:database=#{@db};port=#{@port}"
- @conn=DBI.connect(dbi,@user)
+ @conn=PG::Connection.open(dbname: @db, port: @port, user: @user)
WOK_SQL
end
end
diff --git a/lib/sisu/v5/cgi_sqlite.rb b/lib/sisu/v5/cgi_sqlite.rb
index 4351a64c..2d185f20 100644
--- a/lib/sisu/v5/cgi_sqlite.rb
+++ b/lib/sisu/v5/cgi_sqlite.rb
@@ -172,9 +172,9 @@ module SiSU_CGI_SQLite
begin
require 'cgi'
require 'fcgi'
- require 'dbi'
+ require 'sqlite3'
rescue LoadError
- puts 'cgi, fcgi or dbi NOT FOUND (LoadError)'
+ puts 'cgi, fcgi or sqlite3 NOT FOUND (LoadError)'
end
@stub_default='sisu_sqlite'
@image_src="#{@image_src}"
@@ -247,18 +247,18 @@ module SiSU_CGI_SQLite
%{<font color="#666666" size="2">#{sql_select_endnotes}</font>}
end
def contents
- @conn.select_all(sql_select_body)
+ @conn.execute(sql_select_body)
end
def endnotes
- @conn.select_all(sql_select_endnotes)
+ @conn.execute(sql_select_endnotes)
end
end
WOK_SQL
end
def dbi_connect
<<-'WOK_SQL'
- @dbi="DBI:SQLite3:#{db_sqlite}" #sqlite3 ?
- @conn=DBI.connect(@dbi)
+ @conn=SQLite3::Database.new(db_sqlite)
+ @conn.results_as_hash=true
WOK_SQL
end
end
diff --git a/lib/sisu/v5/sysenv.rb b/lib/sisu/v5/sysenv.rb
index 491ca94f..4b94003c 100644
--- a/lib/sisu/v5/sysenv.rb
+++ b/lib/sisu/v5/sysenv.rb
@@ -2594,7 +2594,7 @@ WOK
else
(opt.mod.inspect =~/--db[=-]["']?sqlite/) \
? "#{Db[:name_prefix_db]}sqlite.cgi" \
- : "#{Db[:name_prefix_db]}pgsql.cgi"
+ : "#{Db[:name_prefix_db]}pg.cgi"
end
end
def sample_search_form_title(organised_by=:language)
diff --git a/lib/sisu/v6/cgi_pgsql.rb b/lib/sisu/v6/cgi_pgsql.rb
index a52b62e3..8372bb70 100644
--- a/lib/sisu/v6/cgi_pgsql.rb
+++ b/lib/sisu/v6/cgi_pgsql.rb
@@ -82,16 +82,15 @@ module SiSU_CGI_PgSQL
opt.lingual.to_s
else 'multi'
end
- if defined? @rc['search'] \
+ @name_of[:db]=if defined? @rc['search'] \
and defined? @rc['search']['sisu'] \
and defined? @rc['search']['sisu']['action'] \
and @rc['search']['sisu']['action'] =~/https?:\/\/\S+?\.cgi/ \
and defined? @rc['search']['sisu']['db'] \
and @rc['search']['sisu']['db'] =~/\S+/
- @name_of[:db]=@rc['search']['sisu']['db']
+ @rc['search']['sisu']['db']
else
- @name_of[:db]=@env.path.stub_pwd #'sisu' #breaks if not present
- false
+ @env.path.stub_pwd #'sisu' #breaks if not present
end
@name_of[:host_url_cgi]=%q{http://#{ENV['HTTP_HOST']}#{ENV['PATH_INFO']}}
@name_of[:host_url_docs]=%q{http://#{ENV['HTTP_HOST']}}
@@ -128,13 +127,6 @@ module SiSU_CGI_PgSQL
default database name: #{@cX.green}#{Db[:name_prefix]}#{@name_of[:db]}#{@cX.off} (#{@name_of[:db]})
db user: #{@cX.green}#{@name_of[:user]}#{@cX.off}
to modify use: #{@cX.brown}sisu --db-pg --db-user='#{@name_of[:user]}'#{@cX.off}
- cgi & db host on: #{@cX.blue}#{@name_of[:host_url_cgi]}#{@cX.off}
- to modify use: #{@cX.brown}sisu --db-pg --webserv-search='#{@name_of[:host_url_cgi]}'#{@cX.off}
- sisu output on: #{@cX.blue}#{@name_of[:host_url_docs]}#{@cX.off}
- to modify use: #{@cX.brown}sisu --db-pg --webserv-output='#{@name_of[:host_url_docs]}'#{@cX.off}
- cgi search form link name: #{@cX.green}#{@name_of[:cgi_script]}#{@cX.off}
- to modify use: #{@cX.brown}sisu --db-pg --cgi-search-form-name='#{@name_of[:cgi_script]}'#{@cX.off}
- #{@cX.fuchsia}(settings priority: command line; sisurc.yml; else defaults)#{@cX.off}
#{@cX.fuchsia}BASED ON ALREADY EXISTING databases#{@cX.off} (default database name: #{@db.psql.db})
NOTE it is first necessary to createdb,
@@ -151,12 +143,12 @@ module SiSU_CGI_PgSQL
#{@cX.brown}createdb #{@db.psql.db}#{@cX.off}
[for a list of existing databases try 'psql --list']"
- now you can use sisu to create the database tables and populate the database with documents
+ you can use sisu to create the database tables and populate the database with documents
sisu --pg --dropall # removes existing postgresql db & tables
sisu --pg --createall -v # creates postgresql db & tables
sisu --pg --update -v *.sst *.ssm # populate the db
- sisu --sample-search-form --pg # creates the postgresql search form
+ sisu --sample-search-form --db-pg # creates the postgresql search form
# this should be done after creating the db
# to be searched
sisu --webrick & # starts ruby webrick web server
@@ -195,9 +187,9 @@ module SiSU_CGI_PgSQL
begin
require 'cgi'
require 'fcgi'
- require 'dbi'
+ require 'pg'
rescue LoadError
- puts 'cgi, fcgi or dbi NOT FOUND (LoadError)'
+ puts 'cgi, fcgi or pg NOT FOUND (LoadError)'
end
@stub_default='#{@name_of[:db]}'
@image_src="#{@image_src}"
@@ -277,10 +269,10 @@ module SiSU_CGI_PgSQL
%{<font color="#666666" size="2">#{sql_select_endnotes}</font>}
end
def contents
- @conn.select_all(sql_select_body)
+ @conn.exec(sql_select_body)
end
def endnotes
- @conn.select_all(sql_select_endnotes)
+ @conn.exec(sql_select_endnotes)
end
end
WOK_SQL
@@ -292,8 +284,7 @@ module SiSU_CGI_PgSQL
end
def dbi_connect
<<-'WOK_SQL'
- dbi="dbi:Pg:database=#{@db};port=#{@port}"
- @conn=DBI.connect(dbi,@user)
+ @conn=PG::Connection.open(dbname: @db, port: @port, user: @user)
WOK_SQL
end
end
diff --git a/lib/sisu/v6/cgi_sqlite.rb b/lib/sisu/v6/cgi_sqlite.rb
index 696b6817..f64c3cf6 100644
--- a/lib/sisu/v6/cgi_sqlite.rb
+++ b/lib/sisu/v6/cgi_sqlite.rb
@@ -172,9 +172,9 @@ module SiSU_CGI_SQLite
begin
require 'cgi'
require 'fcgi'
- require 'dbi'
+ require 'sqlite3'
rescue LoadError
- puts 'cgi, fcgi or dbi NOT FOUND (LoadError)'
+ puts 'cgi, fcgi or sqlite3 NOT FOUND (LoadError)'
end
@stub_default='sisu_sqlite'
@image_src="#{@image_src}"
@@ -247,18 +247,18 @@ module SiSU_CGI_SQLite
%{<font color="#666666" size="2">#{sql_select_endnotes}</font>}
end
def contents
- @conn.select_all(sql_select_body)
+ @conn.execute(sql_select_body)
end
def endnotes
- @conn.select_all(sql_select_endnotes)
+ @conn.execute(sql_select_endnotes)
end
end
WOK_SQL
end
def dbi_connect
<<-'WOK_SQL'
- @dbi="DBI:SQLite3:#{db_sqlite}" #sqlite3 ?
- @conn=DBI.connect(@dbi)
+ @conn=SQLite3::Database.new(db_sqlite)
+ @conn.results_as_hash=true
WOK_SQL
end
end
diff --git a/lib/sisu/v6/sysenv.rb b/lib/sisu/v6/sysenv.rb
index a8879e7a..2c2a8c10 100644
--- a/lib/sisu/v6/sysenv.rb
+++ b/lib/sisu/v6/sysenv.rb
@@ -2675,7 +2675,7 @@ WOK
else
(opt.mod.inspect =~/--db[=-]["']?sqlite/) \
? "#{Db[:name_prefix_db]}sqlite.cgi" \
- : "#{Db[:name_prefix_db]}pgsql.cgi"
+ : "#{Db[:name_prefix_db]}pg.cgi"
end
end
def sample_search_form_title(organised_by=:language)