Execute Ruby code stored in database

Discussion in 'Ruby' started by Petr Janda, Jan 6, 2008.

  1. Petr Janda

    Petr Janda Guest

    Hi,
    I've got a hypothetical question, and im hoping someone can answer it.
    Let's say ive got a MySql server and I store some Ruby code inside a
    column/table/database. Is there anyway I can load this data from a Ruby
    program and execute the code as if it was a part of the program?

    Cheers,
    Petr
    --
    Posted via http://www.ruby-forum.com/.
     
    Petr Janda, Jan 6, 2008
    #1
    1. Advertising

  2. Petr Janda

    hemant Guest

    On Jan 6, 2008 6:31 PM, Petr Janda <> wrote:
    > Hi,
    > I've got a hypothetical question, and im hoping someone can answer it.
    > Let's say ive got a MySql server and I store some Ruby code inside a
    > column/table/database. Is there anyway I can load this data from a Ruby
    > program and execute the code as if it was a part of the program?
    >


    One obvious way is to use 'eval'


    --
    Let them talk of their oriental summer climes of everlasting
    conservatories; give me the privilege of making my own summer with my
    own coals.

    http://gnufied.org
     
    hemant, Jan 6, 2008
    #2
    1. Advertising

  3. Petr Janda

    John Joyce Guest

    On Jan 6, 2008, at 7:01 AM, Petr Janda wrote:

    > Hi,
    > I've got a hypothetical question, and im hoping someone can answer it.
    > Let's say ive got a MySql server and I store some Ruby code inside a
    > column/table/database. Is there anyway I can load this data from a
    > Ruby
    > program and execute the code as if it was a part of the program?
    >
    > Cheers,
    > Petr
    > --
    > Posted via http://www.ruby-forum.com/.
    >

    There could be a few ways to do this.
    One method would be actually loading that text to a string, and the
    string having a file name like name. Then use try to "load
    that_string.rb"
    No idea if that would work.

    The method that would work for sure, get data from DB, save it as
    a .rb text file, "load" the file. Of course, that's pointless if you
    have to do all of that.

    If you just want snippets of code, use eval on the snippets loaded
    from DB.

    Generally speaking, the file system of the OS is going to be faster
    than any DB.
     
    John Joyce, Jan 8, 2008
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. FireListen
    Replies:
    1
    Views:
    516
    James J. Foster
    Jun 27, 2003
  2. Jeff Thur
    Replies:
    2
    Views:
    1,064
    Guest
    Feb 7, 2005
  3. Jeff Thur

    Help with Code to Execute a Stored Procedure

    Jeff Thur, Feb 7, 2005, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    207
  4. Savas Ates
    Replies:
    1
    Views:
    298
    Patrice
    Aug 17, 2004
  5. Etienne Van tonder
    Replies:
    1
    Views:
    134
    Tomaso Tosolini
    Dec 28, 2007
Loading...

Share This Page