0

I'd like to create an app that accesses db (with 1 table) and outputs its table in a window using FXRuby. Is there any way to make it without using query language like in this example:

require 'pg'

conn = PG.connect(dbname: 'testdb', user: 'postgres')    
rows = conn.exec("select * from users")

And without using Ruby on Rails.

I've also tried to launch this example code, but it doesn't work beacause of the problem with installing sqlite3 gem:

require 'fox16' 
require 'sqlite3.rb' 
include Fox 

class TestApp < FXApp 
   def initialize 
      super('Test', 'Test') 
      @db = SQLite3::Database.new('test.db3') 
      @db || raise("can't connect to database") 
   end 

   def db 
      @db 
   end 
end 
T1v1
  • 37
  • 7
  • What do you mean "without using query language"? You're going to have use *some* sort of query to access the database. Incidentally, I use `fox16` and the `sqlite3` gems all the time in my applications, so what *exactly* is the problem installing the `sqlite3` gem? – varro Apr 01 '19 at 19:22
  • @varro I'm using win 10 + ruby 2.5.3 and when I try to "gem install sqlite3" it fails. – T1v1 Apr 01 '19 at 20:00
  • You should try to be as explicit as possible in your error reports, but I will guess that here that you do not have your development environment set up correctly. The fox16 gem is a C/C++ extension, which means you will need to compile it. Do you have a compiler installed? And what is your development environment? – varro Apr 01 '19 at 20:18
  • @varro I've installed ruby interpreter from rubyinstaller.org/ and use powershell to launch code. – T1v1 Apr 01 '19 at 20:53
  • But do you have a *compiler*? I use MSYS myself as a development environment, but going to the rubyinstaller website, it looks like you can install MSYS2/DevKit under Add-ons. Do you have that? – varro Apr 01 '19 at 21:05
  • @varro yes, it's installed, but not that sqlite3 gem – T1v1 Apr 01 '19 at 21:39
  • Just to double-check, if you run the command `gem list`, do you see a line for "fxruby" but *not* for "sqlite3"? And when you run `gem install sqlite3`, what is the *exact* error message you see? (Just saying "it fails" is not *nearly* good enough.) – varro Apr 01 '19 at 21:49
  • @varro since the first time I've tried to 'gem install sqlite3' it returns:"... checking for -ldl... no checking for dlopen()... no missing function dlopen *** extconf.rb failed *** Could not create Makefile due to some reason, probably lack of necessary libraries and/or headers. Check the mkmf.log file for more details. You may need configuration options...". – T1v1 Apr 01 '19 at 21:56
  • @varro I've googled this problem but it only has a solution for ruby-on-rails with changing sqlite3 source in Gemfile – T1v1 Apr 01 '19 at 21:57
  • oh. seems like fxruby was left behind a long time ago... :( – T1v1 Apr 01 '19 at 22:17
  • Um... what does that mean exactly? Does that mean you have neither the fxruby or the sqlite3 gems installed? As I said, I've been using both for years. – varro Apr 01 '19 at 22:24
  • @varro fxruby gem is working fine, but I can't use sqlite3 gem, because of that error "... missing function dlopen ..." – T1v1 Apr 01 '19 at 22:27
  • @varro ann attempt to get sqlite3 gem https://i.imgur.com/IxTZwbb.png – T1v1 Apr 01 '19 at 22:35
  • The next thing to do is look up that "mkmf.log" file cited in the primary error message and scan it for more details. – varro Apr 01 '19 at 23:16
  • @varro I appreciate your help! So many times you've answered me already, but I don't know what to do with this file, it's large enough and there's no way to find this problem in the net. (the pdf of mkmf: https://drive.google.com/file/d/1REZqnX2-XDf07retbEOW0vOHamiATU82/view?usp=sharing) – T1v1 Apr 01 '19 at 23:32

1 Answers1

0

It looks like the following should solve your problem (see this reference):

ridk exec pacman -S mingw-w64-x86_64-dlfcn
gem install sqlite3
varro
  • 2,382
  • 2
  • 16
  • 24
  • Thank you very much for your help! I should have googled my error message in the proper way – T1v1 Apr 03 '19 at 10:17