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

    How to Connect Ruby to MySQL

    Scheduled Pinned Locked Moved Developers' Forum
    12 Posts 5 Posters 2.1k Views 5 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.
    • Dan RathbunD Offline
      Dan Rathbun
      last edited by

      @hchitrakar said:

      #!/usr/bin/ruby -w

      1) ... this is the "shebang" for a Unix-like Ruby install. Windows does not "read a file's first line, then decide what program to use for the file."

      Windows uses file associations... and on Windows, most developers prefer to associate their "rb" files with the editor that they use to program with.

      2) Do you even have a FULL Ruby installation on your computer ?? (Microsoft would NEVER distro their OS, with an Open Source scripting language that they didn't invent (or have a large part in the development of... the brats!)
      If not.. and your on Sketchup v8+

      Ruby Binary Installer:

      • Ruby (v1.8.6-p287) Windows One-Click Installer

      3) Get my !loadpaths.rb script, and either use it... or a condensed version of what it does to push the Ruby lib paths into the $LOAD_PATH array.

      THEN ... you'll be ready to use standard libs to connect to a database...

      I'm not here much anymore.

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

        Thanks!

        Can you show me how to extract tables of MySQL in Ruby?

        1 Reply Last reply Reply Quote 0
        • TIGT Offline
          TIG Moderator
          last edited by

          hchitrakar !
          You just "reported" the last post!
          I don't think you meant to do that - please use the Reply button.
          😒

          TIG

          1 Reply Last reply Reply Quote 0
          • Dan RathbunD Offline
            Dan Rathbun
            last edited by

            FYI : It may be more to your benefit, to ask basic / standard Ruby questions, or how to deal with extended Ruby libraries, in one of the "normal" Ruby forums.

            Link Preview Image
            Ruby-Forum

            Online Community that helps beginners learn Ruby, and coders solve Ruby coding problems since 2005

            favicon

            Ruby-Forum (www.ruby-forum.com)

            You can also do a search first to see if your question has already been asked (and most likely it has.) Replies often have code samples included.

            I'm not here much anymore.

            1 Reply Last reply Reply Quote 0
            • Dan RathbunD Offline
              Dan Rathbun
              last edited by

              @hchitrakar said:

              Can you show me how to extract tables of MySQL in Ruby?

              NO.. sorry.

              I have no idea which dB interface library that you will choose !!
              You will need to read the instructions or study the methods of the library that you choose to use.

              If the Ruby standard libraries do not have what you want, you may need to use a 3rd party library gem.. so check rubygems.org

              And you will need to know and understand Ruby first...
              see: Ruby Newbie's Guide to Getting Started

              I'm not here much anymore.

              1 Reply Last reply Reply Quote 0
              • J Offline
                Jim
                last edited by

                Is this for a personal project, free plugin, commercial plugin? If you use extra libraries, do you plan on distributing them with the plugin?

                They way I would do it is to use a WebDialog to communicate with the database through php scripts on the server, but this may not be applicable to your requirements.

                Hi

                1 Reply Last reply Reply Quote 0
                • Dan RathbunD Offline
                  Dan Rathbun
                  last edited by

                  @jim said:

                  The way I would do it is to use a WebDialog to communicate with the database ...

                  Windows is distro'd with the TDC.ocx (Tabular Data Control Active-X extension,) that can link to dB tables and CSV files, etc. A change in the data is immediately seen in the webpage element so linked.

                  About Microsoft Tabular Data Control

                  I'm not here much anymore.

                  1 Reply Last reply Reply Quote 0
                  • J Offline
                    Jim
                    last edited by

                    That's really interesting, Dan. It deserves a more in-depth look into the potential.

                    Hi

                    1 Reply Last reply Reply Quote 0
                    • Dan RathbunD Offline
                      Dan Rathbun
                      last edited by

                      Here's an example page, that lists HTML colors. Click on any column heading, and the table resorts by that column. (One of the most useful features of dynamic HTML tables using the TDC.)
                      Dynamic Color Reference

                      One drawback, is that it's deprecated beginning with IE9... But, Sketchup is using the WebBroswer control that runs in EmulateIE7 mode by default. So it should work as long as the user has the **tdc.ocx** file on their computer. (It's located in "C:\WINDOWS\system32" on XP.)

                      And then you can also force the browser mode via a META tag:
                      %(#8000BF)[<META http-equiv="X-UA-Compatible" content="IE=7" > <!-- can be: IE=5,IE=7,IE=EmulateIE7,IE=8,IE=EmulateIE8,IE=9 -->]
                      .. just in case they change the default mode, in the future.

                      Refering to: META Tags and Locking in Future Compatibility

                      @unknownuser said:

                      By default, Internet Explorer 8 uses EmulateIE8 mode to display pages loaded from the Internet Zone. Web pages loaded from the Intranet Zone or with the Web Browser control are displayed in EmulateIE7 mode. These defaults can be changed.

                      and ...

                      @unknownuser said:

                      EmulateIE7 mode tells Windows Internet Explorer to use the <!DOCTYPE> directive to determine how to render content. Standards mode directives are displayed in Internet Explorer 7 Standards mode, and Quirks mode directives are displayed in IE5 mode. Unlike IE7 mode, EmulateIE7 mode respects the <!DOCTYPE> directive.

                      If Microsoft had just released a cross-platform cross-browser version, it wouldn't need to be deprecated. (Perhaps someone else in the OpenSource community has??)

                      It would be nice if we had compatible TDC controls for both Trident and WebKit. Oh wait a min... I actually just loaded that sample page in Chrome, and it works fine !!
                      I'd like to know what happens on a Mac, in Safari, when that page is loaded...

                      I'm not here much anymore.

                      1 Reply Last reply Reply Quote 0
                      • tbdT Offline
                        tbd
                        last edited by

                        Dynamic Color Reference works perfectly as it uses plain javascript.
                        Examples that use TDC will not work as .ocx is windows only.

                        SketchUp Ruby Consultant | Podium 1.x developer
                        http://plugins.ro

                        1 Reply Last reply Reply Quote 0
                        • Dan RathbunD Offline
                          Dan Rathbun
                          last edited by

                          Thanks Tavi.. dang it.. dat's a bummer... oh well then it's SQLite3

                          I'm not here much anymore.

                          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