Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6737391
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T11:14:36+00:00 2026-05-26T11:14:36+00:00

I have an application using Ruby on Rails where a user will be providing

  • 0

I have an application using Ruby on Rails where a user will be providing a connection string and will be requesting data from their database. I found a link that get’s me part of the way and thought to post a question to see if anyone has experience in this. Here’s something I’ve found:

def fetch_value
    sql = ActiveRecord::Base.connection();
    sql.execute "SET autocommit=0";
    sql.begin_db_transaction 
    id, value =
    sql.execute("SELECT id, value FROM sometable WHERE used=0 LIMIT 1 FOR UPDATE").fetch_row;
    sql.update "UPDATE sometable SET used=1 WHERE id=#{id}";
    sql.commit_db_transaction 

    value;
end

I’m writing this application to be similar to phpmyadmin but in rails. I don’t know the structure of the tables, but I would like to essential return json results of the queries they specify.

What I need is to be able to create a connection, retrieve a list of results and output the results in json without knowing too much. Any help would be appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T11:14:36+00:00Added an answer on May 26, 2026 at 11:14 am

    Active Record is a Object Relational Mapping library which means it maps (known) tables to objects in Ruby. Active Record does expose ways to get directly to SQL, as you’ve done in your example, but it is not a ‘normal’ use case. In this case you would need something that is more generic.

    You could have a look at Sequal. It is a Ruby library that abstracts SQL syntax away but not quite to the extend of Active Record where you have a strict table to object mapping.

    If Sequal still gets in the way you can use the raw MySql Ruby module. Very powerful but should probably be a last resort because of the manual work you have to do.

    Also remember that you could still use Active Record for your application database – perhaps users need to register and sign up. Sequal or the Mysql Ruby module is then used where your users enter db details directly.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a ruby on rails 3.0 application which will need a database containing
I have created a blog application using Ruby on Rails which includes the ability
I have built a very simple blog application using Ruby on Rails. New to
I have a Php application using stream_socket_client(), to get data through tcp from a
I have created a blog application using Ruby on Rails and have just added
I have a Ruby on Rails application that will be a CMS in way
I'm using Rails 2.3.4/Ruby 1.9.1 for my application. In the view I have this
I have built a Ruby on Rails application that allows users to track their
Our team have built a web application using Ruby on Rails. It currently doesn't
I have a Ruby application (not using Rails) that use my own Ruby gems.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.