Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

MYSQLSafe

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

MYSQLSafe

  • 0.1.5.1
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

MYSQLSafe

MYSQLSafe abstracts some common MYSQL connection and query actions Specifically it

  • Ensures connection closure
  • Returns an Array (instead of MYSQL object)
  • Rescues and prints errors
  • Sanitizes input
  • Encodes queries
  • Encloses table and column names in backticks (like this.that)

Installation

Add this line to your application's Gemfile:

gem 'MYSQLSafe'

And then execute:

$ bundle

Or install it yourself as:

$ gem install MYSQLSafe

Usage

MYSQLSafe allows you to optionally set

  • host

  • database

  • user

  • password

  • encoding

      safe_sql_connect = MYSQLSafe::Base.new()
      safe_sql_connect.user = 'username'
      safe_sql_connect.host = 'myhost'
      safe_sql_connect.password = ENV['MYSQLPASSWORD']
      safe_sql_connect.database = 'databasename'
      safe_sql_connect.encoding = 'iso-8859-1' # otherwise defaults to 'utf-8'
    

MYSQLSafe has one other public function which allows you to pass a MYSQL query

	safe_sql_connect.connect_safe("SELECT * FROM tablename LIMIT 1;")

And it returns an Array

	#=> [["1", "Sam", "Areas Of My Expertise"], ["2", "Caz", "1Q84"], ["3", "Kyle", "How I Became A Famous Novelist"]]

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

Contact

Shoot me an email with any questions or ideas.

FAQs

Package last updated on 12 Dec 2013

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc