examples/sqlc.rb in rbcurse-1.1.3 vs examples/sqlc.rb in rbcurse-1.1.4
- old
+ new
@@ -24,10 +24,11 @@
require 'rbcurse/rtabbedpane'
# pls get testd.db from
# http://www.benegal.org/files/screen/testd.db
# or put some other sqlite3 db name there.
+# or create using sqlite3 testd.db < data.txt
## must give me @content, @columns, @datatypes (opt)
class Datasource
# attr_reader :field_length # specified by user, length of row in display table
attr_accessor :columns # names of columns in array
@@ -47,10 +48,11 @@
# @command = nil
instance_eval(&block) if block_given?
end
def connect dbname
+ raise " #{dbname} does not exist. Please fetch from http://www.benegal.org/files/screen/testd.db" if !File.exists?(dbname)
@db = SQLite3::Database.new(dbname)
end
# get columns and datatypes, prefetch
def get_data command
@columns, *rows = @db.execute2(command)
@@ -262,10 +264,11 @@
#atable.get_table_column_model.bind(:TABLE_COLUMN_MODEL_EVENT){|e| eventlabel.text = "Event: #{e}"}
tablist_ht = 6
mylist = @db.get_data "select name from sqlite_master"
# mylist is an Array of SQLite3::ResultSet::ArrayWithTypesAndFields
+ raise "Database contains no tables! I need some tables" unless mylist
mylist.collect!{|x| x[0] } ## 1.9 hack, but will it run on 1.8 ??
$listdata = Variable.new mylist
tablelist = Listbox.new @form do
name "tablelist"
row 1
@@ -410,10 +413,12 @@
include RubyCurses::Utils
begin
# Initialize curses
VER::start_ncurses # this is initializing colors via ColorMap.setup
- $log = Logger.new("view.log")
+ #$log = Logger.new("view.log")
+ $log = Logger.new(ENV['LOGDIR'] || "" + "view.log")
+
$log.level = Logger::DEBUG
colors = Ncurses.COLORS
$log.debug "START #{colors} colors SQLC demo "