Error While loading sqlite3 in ruby

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.

ruby 2.5.5p157 (2019-03-15 revision 67260) [x64-mingw32]

Rails 5.2.3
3.27.2 2019-02-25 16:06:06 bd49a8271d650fa89e446b42e513b595a717b9212c91dd384aab871fc1d0f6d7

I’m a bit confused. How does this relate to SketchUp?

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 =‘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(’,’)} );”)

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…

could pls explain how this can be done or where i can find stuff related to this

Thanks for the guidance

@susketch17, please read:

The magnifying glass icon (:mag:) at the top right is the search feature.
Use it and you’ll find several topic threads about SQLite under SketchUp.

Thanks for your feedback Dan. Will look into that. Feeling blessed by your’s, TiG’s and eneroth3 for the guidance in the forum :slight_smile:

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.

You need to run the file inside SketchUp and not inside Eclipse IDE.
Your SketchUp installation would also need to have the SQLite3 gem installed.

Again, others have had major problems using SQLite in the past from inside SketchUp, so see the other forum treads on this.

hi kengey ,

How to check this out,

Thanks Dan., will look into it.

the same error inside sketchup also
"require ‘sqlite3’
Error: #<LoadError: cannot load such file – sqlite3>
C:/Program Files/SketchUp/SketchUp 2017/Tools/RubyStdLib/rubygems/core_ext/kernel_require.rb:54:in require' C:/Program Files/SketchUp/SketchUp 2017/Tools/RubyStdLib/rubygems/core_ext/kernel_require.rb:54:inrequire’



Please see Installing ruby gems in Sketchup

That message refers to installing another gem. Ignore step #1, as the dll issue doesn’t affect sqlite3.

As to the gem, it is located at:


It needs to be downloaded.

So, once you have the gem and downloaded & extracted, in the SketchUp Ruby console::

require '<path>/su_gem.rb'

SUGem.install '-lN <path>/sqlite3-1.4.0.mspgreg-x64-mingw32.gem'

You should be able to use SQLite3 with SU2019 or SU2017/18.

The gem is compiled statically with SQLite3, so no ‘DevKit’ or additional installation is needed.

Thanks Greg, will check and revert.

this file file located where?

Sorry, it’s attached to this message:

Thank you!

it shows false when called ‘require sqlite3’

What was the response to the following:



Maybe a better description of what you should be doing & why. The goal is to install a local gem file.

  1. 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.

  2. There are few files contained in, 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.

  3. 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'
  1. 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…

  2. Once you have that on your system, the line


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 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.


One other thing. In your first message you showed


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.

I tried this with SU 2018.

When I entered:


The response was:

Successfully installed sqlite3-1.4.0.mspgreg-x64-mingw32
1 gem installed

Also, the output from SUGem.list should show the gem name.

Lastly, using the example from, every thing ran fine (created a database, added records, read records).

If it’s working in SU 2018, I’m sure it will do the same in SU 2019. Please read the instructions again…