Hi,
i am new to ruby [programming. Attached herewith the screen shot of error console while loading in eclipse.
Where i am missing out. could u guys help it out
i am using the following versions.
hi.,
I am trying to connect an sql database using the ruby from sketchup for read and write the data.
The program of ruby script i just tried to run in eclipse ide, but i am unsucessful.
This is the snippet of the code i try to run, but throws error
require ‘win32ole’
require ‘sqlite3’
‘# Connect to a running instance of Excel’
xl = WIN32OLE.connect(‘Excel.Application’)
<# Get the active workbook/>
wb = xl.ActiveWorkbook
<# Create the SQLite3 database/>
db = SQLite3::Database.new(‘excel.db’)
<# Create a database table for each worksheet />
<# in the workbook/>
wb.Worksheets.each do |ws|
# Grab all values from worksheet into a
# 2-dimensional array
data = ws.UsedRange.Value
# Grab first row of data to use as field names
field_names = data.shift
# Create database table using worksheet name and
# field names
db.execute(“CREATE TABLE [#{ws.Name}]
( #{field_names.join(‘,’)} );”)
# For each row of data…
data.each do |row|
# …single-quote all field values…
row.collect! { |f| f = “'” + f.to_s + “'” }
# …and insert a new record into the
# database table
db.execute(“INSERT INTO [#{ws.Name}] VALUES
( #{row.join(‘,’)} );”)
end
end`
Please edit your post and put your lines of code inside </> tags [or ```xxx```] so its appearance not messed up…
From the error message it’s failing in line #2 when it can’t find ‘sqlite3’ to load it…
I think you should be running your SketchUp based files from within SketchUp [it uses its own Ruby-subset]
You cannot run separate Ruby files and hope they magically connect with SketchUp’s own set - however, you can ‘require’ additional Ruby methods into SketchUp’s own, given the proper path is specified…
Well, the error is pretty easy to understand: Error: #<LoadError: cannot load such file -- sqlite3>
You don’t have the library installed in any of the known install directories.
Maybe a better description of what you should be doing & why. The goal is to install a local gem file.
RubyGems is designed to be a console application. In SketchUp (SU), the ruby console is more like an IRB session, where you can directly type ruby commands into it.
There are few files contained in su_utils.zip, but one of them (su_gem.rb), allows one to use the RubyGems parameter style used in a normal console with RubyGems in the SU Ruby console.
The following command loads this file, which creates a module (SUGem). You should replace “<path>” with the path to wherever you unzipped the file.
require '<path>/su_gem.rb'
Before continuing, you need to download the gem file (sqlite3-1.4.0.mspgreg-x64-mingw32.gem) from the page listed above. Nothing involving SU, just a browser…
install the gem. Again, you should replace “<path>” with the path to wherever the file is located. FYI, the 'l' option tells RubyGems that it’s a local operation, it shouldn’t connect to RubyGems.org to look for the gem. The 'N' option tells it to not generate rdoc files for the gem.
I’m about 99.9% sure the gem works. It passed all the sqlite3 tests using Ruby versions 2.2 thru 2.6.
That is a stand-alone version of Ruby that you installed. There is essentially no connection between it and the version of Ruby installed by SketchUp. The current installation of SketchUp does not allow for any way to share gems between it and a stand-alone Ruby version.
FYI, they (Trimble) could change that by allowing SU Ruby to install or use gems in the standard RubyGems --user-install folder.