sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    Connecting Sketchup's ruby with MYSQL database

    Scheduled Pinned Locked Moved Developers' Forum
    7 Posts 4 Posters 1.7k Views 4 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • O Offline
      omarh
      last edited by

      Hello everyone,
      I'm trying right now to connect my ruby scripts for sketchup to a MYSQL database. The database is not on the same computer as mine, I'm the client, and there is a server which has this database. And yeah I'm using a windows 7, 64-bit, and I have downloaded all the remaining parts for ruby as I've read on some old threads on the forum. The ruby version I have, or sketchup has is 1.8.6. I tried loads of softwares, but usually there is an error that doesn't make me able to install it and connect to database, and usually there is an error that keeps repeating many times. So I really need help because I tried almost everything and don't know what to do. I'll put each software's case and my steps and the errors:

      -ODBC for Ruby: ODBC was installed successfully and was able to connect to the database, but the connection between ruby and the ODBC wasn't successful. I followed this link: http://www.ch-werner.de/rubyodbc/ to get the instalation steps. I downloaded the source of version 0.9995, and then entered this command: $ ruby -Cext extconf.rb, and here is the error I got: checking for version.h... no
      checking for sql.h... no
      ERROR: sql.h not found
      *** 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.

      Provided configuration options:
      --with-opt-dir
      --without-opt-dir
      --with-opt-include
      --without-opt-include=${opt-dir}/include
      --with-opt-lib
      --without-opt-lib=${opt-dir}/lib
      --with-make-prog
      --srcdir=.
      --curdir
      --ruby=C:/Ruby/bin/ruby
      --with-odbc-dir
      --without-odbc-dir
      --with-odbc-include
      --without-odbc-include=${odbc-dir}/include
      --with-odbc-lib
      --without-odbc-lib=${odbc-dir}/lib
      and I have no idea how to solve that, and that error is the usual error I get for most softwares.

      -The second software used was the Ruby/MYSQL from MYSQL at: http://www.tmtm.org/en/ruby/mysql/. I downloaded version 0.2.6, and followed the steps, and on the first step ruby ./test.rb hostname user passwd I got the same error again.

      • The third software was MYSQL/Ruby from also MYSQL at http://www.tmtm.org/en/mysql/ruby/ and downloaded from rubyforge version 2.8.2, and just the same error with the first step of installation

      -Fourt software was the DBI software which also didn't work

      I need help, I tried everything.

      Thanks alot

      1 Reply Last reply Reply Quote 0
      • danielbowringD Offline
        danielbowring
        last edited by

        Off topic but tangent: Setting that up is going to be hell (version support, requirements, ...), and it's going about it the "wrong" way anyway. You should look at making a web service and query information using that, not using sql directly. This will be easier in the long term and easier to manage auth/security. What's more, you'll be able to deal with the information using net/http and then whatever data serialization method you use.

        If you're really determined to get a direct connection to work, you're missing the header files for ODBC. You'll need to go get a distro/version compatible that's with your compiler and sketchups ruby. There's a version by Microsoft available somewhere and I'd guess that it would be a good choice, but I've never researched/tried.

        I do recommend the web-service approach, though.

        1 Reply Last reply Reply Quote 0
        • O Offline
          omarh
          last edited by

          But all what I need is just a simple connection between my sketchup and the database to only save some coordinates of objects there to be used later by anyone, using a simple mysql table and each time just adding a couple of rows. I have no idea what advantages would the web service, or even if I want to do that, how should I start

          1 Reply Last reply Reply Quote 0
          • H Offline
            honkinberry
            last edited by

            If your data needs are truly that simple, then you definitely don't need MySQL.
            Consider that to even install MySQL now, users would have to navigate their web site, find the right installer, follow a rather complicated install process... This is just madness, if you are just trying to save a few coordinates.
            Better solutions would be to save as XML or similar text file, with Sketchup.write_default, or with a WebDialog that accesses your remote MySQL data through PHP.
            Having a local structured query language is of course handy, but since you're not talking multi-user, if you were to integrate something, go with SQLite, which is intended for exactly this scenario.

            --J

            1 Reply Last reply Reply Quote 0
            • M Offline
              mptak
              last edited by

              Any tips for going the SQLite route?

              1 Reply Last reply Reply Quote 0
              • H Offline
                honkinberry
                last edited by

                Perhaps start with something like this:
                http://zetcode.com/db/sqliteruby/

                --J

                1 Reply Last reply Reply Quote 0
                • danielbowringD Offline
                  danielbowring
                  last edited by

                  Oh, if you're only intending to use the data locally, then any remote data source would be overkill. If you want to just save it to the model, you can just save it as an attribute to the model. Entity#(g|s)et_attribute can store a few different types, including Point3d objects.

                  
                  model = Sketchup.active_model
                  # Save array of points to the model
                  model.set_attribute('my-points', 'some-key', [ORIGIN, Geom;;Point3d.new(1, 2, 3)])
                  # Get the points from the model, or an empty list if none are present
                  my_points = model.get_attribute('my-points', 'some-key', [])
                  
                  
                  1 Reply Last reply Reply Quote 0
                  • 1 / 1
                  • First post
                    Last post
                  Buy SketchPlus
                  Buy SUbD
                  Buy WrapR
                  Buy eBook
                  Buy Modelur
                  Buy Vertex Tools
                  Buy SketchCuisine
                  Buy FormFonts

                  Advertisement