diff options
author | Ralph Amissah <ralph@amissah.com> | 2008-12-22 01:08:06 -0500 |
---|---|---|
committer | Ralph Amissah <ralph@amissah.com> | 2008-12-24 00:34:18 -0500 |
commit | 71223cf6cd035b3e395f6d4c3e4c41b79ed29510 (patch) | |
tree | 58fe17f8c2340792924b0eb2eeea51a8e9805e53 /lib/sisu/v0/db_remove.rb | |
parent | SiSU's sqlite module still broken for the time being: inconsistent ruby dbi api (diff) |
sqlite3 fix, populate do using rb sqlite3 driver directly (rb dbi problematic
at present)
sqlite fix, change ruby driver used to populate sisu sqlite3 db to rb sqlite3
for the time being. Use rb sqlite3 driver directly rather (than more convenient
when working) rb dbi interface to populate content. Used to bypass problems
with rb dbi sqlite3 interface noted in sisu 0.66.2 (2008-04-25) and 0.66.3
(2008-05-11) that have have persisted (apparently worked at end 2007 (v.0.62.4)
and start of 2008 (v.0.64.0)
* sqlite dropall, fix
* fix to auto-generated sqlite cgi script sample, only works if at least one
existing populated sisu sqlite database is found during the generation process
Diffstat (limited to 'lib/sisu/v0/db_remove.rb')
-rw-r--r-- | lib/sisu/v0/db_remove.rb | 55 |
1 files changed, 27 insertions, 28 deletions
diff --git a/lib/sisu/v0/db_remove.rb b/lib/sisu/v0/db_remove.rb index fef4e797..a869bd24 100644 --- a/lib/sisu/v0/db_remove.rb +++ b/lib/sisu/v0/db_remove.rb @@ -67,22 +67,35 @@ module SiSU_DB_remove @db=SiSU_Env::Info_db.new end def remove - del=@conn.select_one(%{ SELECT tid FROM metadata WHERE filename LIKE '#{@opt.fns}'; }) - if del - del_id=del.join - #@conn.execute("BEGIN") - sql_entry=<<SQL -DELETE FROM endnotes WHERE metadata_tid = '#{del_id}'; -DELETE FROM endnotes_asterisk WHERE metadata_tid = '#{del_id}'; -DELETE FROM endnotes_plus WHERE metadata_tid = '#{del_id}'; -DELETE FROM documents WHERE metadata_tid = '#{del_id}'; -DELETE FROM urls WHERE metadata_tid = '#{del_id}'; -DELETE FROM metadata WHERE tid = '#{del_id}'; -SQL - @conn.execute(%{#{sql_entry}}) + driver_sqlite3 = true if @conn.inspect.match(/^(.{10})/)[1] == @db.sqlite.conn_sqlite3.inspect.match(/^(.{10})/)[1] + del_id=if driver_sqlite3 + @conn.get_first_value(%{ SELECT tid FROM metadata WHERE filename LIKE '#{@opt.fns}'; }).to_i + else + x=@conn.select_one(%{ SELECT tid FROM metadata WHERE filename LIKE '#{@opt.fns}'; }) + del=if x; x.join.to_i else nil + end + end + if del_id + sql_entry=[ + "DELETE FROM endnotes WHERE metadata_tid = '#{del_id}';", + "DELETE FROM endnotes_asterisk WHERE metadata_tid = '#{del_id}';", + "DELETE FROM endnotes_plus WHERE metadata_tid = '#{del_id}';", + "DELETE FROM documents WHERE metadata_tid = '#{del_id}';", + "DELETE FROM urls WHERE metadata_tid = '#{del_id}';", + "DELETE FROM metadata WHERE tid = '#{del_id}';", + ] + if driver_sqlite3 + @conn.transaction + sql_entry.each do |s| + @conn.execute(s) + end + @conn.commit if driver_sqlite3 + else + s=sql_entry.join(' ') + @conn.execute(s) + end if @opt.cmd =~/M/ @file.puts sql_entry if @opt.cmd =~/M/ - #else @conn.execute(%{#{sql_entry}}) end else tell=SiSU_Screen::Ansi.new(@opt.cmd,"no such file in database #{@db.psql.db}::#{@opt.fns}") @@ -92,17 +105,3 @@ SQL end end __END__ -DELETE FROM endnotes WHERE metadata_tid = '#{del_id}'; -DELETE FROM endnotes_asterisk WHERE metadata_tid = '#{del_id}'; -DELETE FROM endnotes_plus WHERE metadata_tid = '#{del_id}'; -DELETE FROM documents WHERE metadata_tid = '#{del_id}'; -DELETE FROM urls WHERE metadata_tid = '#{del_id}'; -DELETE FROM metadata WHERE tid = '#{del_id}'; -/* -DELETE FROM documents WHERE documents.metadata_tid = '#{del_id}'; -DELETE FROM endnotes WHERE endnotes.metadata_tid = '#{del_id}'; -DELETE FROM endnotes_asterisk WHERE endnotes_asterisk.metadata_tid = '#{del_id}'; -DELETE FROM endnotes_plus WHERE endnotes_plus.metadata_tid = '#{del_id}'; -DELETE FROM urls WHERE urls.metadata_tid = '#{del_id}'; -DELETE FROM metadata WHERE metadata.tid = '#{del_id}'; -*/ |