
Security News
New Website “Is It Really FOSS?” Tracks Transparency in Open Source Distribution Models
A new site reviews software projects to reveal if they’re truly FOSS, making complex licensing and distribution models easy to understand.
= MdlSql
Modular Sql
Modular Sql is a modular query builder that enables a high database compatibility, usage easiness and dynamic construction. It is intended to allow any kind of query in any database, but will, at the moment, only handle relatively simple ones to most common databases.
It actually does a similar job to ActiveRecord, but I believe it may allow a better control in some aspects as it lies somehow between raw queries and that uberuseful gem.
Actual situation:
== Usage
Select: result = MdlSql::select.from(:users).where(:role, 2, '=').execute
This will build and execute the following query: SELECT * FROM users WHERE role = 2
We finally iterate over the results: results.each do |row| puts row[:username] end
You can read more about the usage of the MysqlResult object @ https://github.com/brianmario/mysql2usage
When selecting columns use .cols()/.columns(), which can receive a Hash or an Array. In case a Hash is passed, the key will be the alias and the value the actual name of the column (f.e. 'users.username').
Insert: result = MdlSql::insert.into(:users).cols(:username, :role).values('admin',2).execute
Update: result = MdlSql::update(:users).set(:role => '1').where(@username = 'default'").execute
Updating follows mysql building way. Remember that you can still use .table() if you feel more comfortable.
== Fast documentation
===#table(table_name, table_alias) (#from, #into): Select table to use.
=== #where(first_term, sencond_term, operator): Where condition. This can be used both passing each separate term (recommended) and introducing the whole comparison as the first_term (i.e. .where('id = 1')). The first way will provide a higher compatibility with other databases, but may not be as useful when needing more than a simple condition.
TODO: expand where to include AND, OR, etc. in order to be able to concatenate many conditions.
=== #columns(*values)
== Installing
gem install mdlsql
If you're going to use mysql, mysql2 is required. Please follow these instructions to install: https://github.com/brianmario/mysql2#installing (really worth it, even if you're not going to use mdlsql ;) ).
== Useful Links
RubyGems: https://rubygems.org/gems/mdlsql
== License
Copyright (C) 2013 MdlSql contributers
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.
FAQs
Unknown package
We found that mdlsql demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
A new site reviews software projects to reveal if they’re truly FOSS, making complex licensing and distribution models easy to understand.
Security News
Astral unveils pyx, a Python-native package registry in beta, designed to speed installs, enhance security, and integrate deeply with uv.
Security News
The Latio podcast explores how static and runtime reachability help teams prioritize exploitable vulnerabilities and streamline AppSec workflows.