1

I want to provide the ability to query the underlying mysql db on a rails-powered site to visitor on the web. The most transparent way seems to be able to take the text in a textbox and pass it to an sql connection.

However, I'd want to hide the user/password details and only make certain content tables available. Also, I only want to provide read access. Is there a convenient way to do this? It would be better if there were convenient view helpers too. Any gems like this? Perhaps something similar to PHP's MyAdmin?

highBandWidth
  • 16,751
  • 20
  • 84
  • 131

1 Answers1

1

The solution to this is more about configuring your database rather than finding special code.

You need to create a user in your MySQL database and grant read-only privilege to a subset of tables of your choice. Use this user in your connection string for queries from your "raw" SQL page. This is the only place you'll have to change code and all it involves is using a different connection string from your other code.

Here's an object-specific example of granting read-only permissions to a user.

To help manage this issue on the server you could make use of a schema.

Community
  • 1
  • 1
Paul Sasik
  • 79,492
  • 20
  • 149
  • 189