Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
ruby-mysql is a MySQL client library. It is written entirely in Ruby. Therefore libmysqlclient is not required and no compilation is required during installation.
gem install ruby-mysql
require 'mysql'
my = Mysql.connect('mysql://username:password@hostname:port/dbname?charset=utf8mb4')
my.query("select col1, col2 from tblname").each do |col1, col2|
p col1, col2
end
stmt = my.prepare('insert into tblname (col1,col2) values (?,?)')
stmt.execute 123, 'abc'
MySQL type | Ruby class |
---|---|
NULL | NilClass |
INT | Integer |
DECIMAL | BigDecimal |
FLOAT, DOUBLE | Float |
DATE | Date |
DATETIME, TIMESTAMP | Time |
TIME | Float (as seconds) |
YEAR | Integer |
CHAR, VARCHAR | String |
BIT | String |
TEXT, BLOB, JSON | String |
3.0:
pp my.query('select 123,123.45,now(),cast(now() as date)').fetch.map{[_1, _1.class]}
#=> [["123", String],
# ["123.45", String],
# ["2022-11-15 00:17:11", String],
# ["2022-11-15", String]]
4.0:
pp my.query('select 123,123.45,now(),cast(now() as date)').fetch.map{[_1, _1.class]}
#=> [[123, Integer],
# [0.12345e3, BigDecimal],
# [2022-11-15 00:17:17 +0900, Time],
# [#<Date: 2022-11-15 ((2459899j,0s,0n),+0s,2299161j)>, Date]]
To specify cast: false
, you get the same behavior as in 3.0.
my.query('select 123,123.45,now(),cast(now() as date)', cast: false).fetch.map{[_1, _1.class]}
#=> [["123", String],
# ["123.45", String],
# ["2022-11-15 00:19:18", String],
# ["2022-11-15", String]]
It can also be specified during Mysql.new and Mysql.connect.
my = Mysql.connect('mysql://user:pass@localhost/', cast: false)
Changing mysql.default_options will affect the behavior of subsequently created instances.
my1 = Mysql.connect('mysql://user:pass@localhost/')
Mysql.default_options[:cast] = false
my2 = Mysql.connect('mysql://user:pass@localhost/')
pp my1.query('select 123,123.45,now(),cast(now() as date)').fetch.map{[_1, _1.class]}
#=> [[123, Integer],
# [0.12345e3, BigDecimal],
# [2022-11-15 00:26:09 +0900, Time],
# [#<Date: 2022-11-15 ((2459899j,0s,0n),+0s,2299161j)>, Date]]
pp my2.query('select 123,123.45,now(),cast(now() as date)').fetch.map{[_1, _1.class]}
#=> [["123", String],
# ["123.45", String],
# ["2022-11-15 00:26:09", String],
# ["2022-11-15", String]]
3.0:
res = my.query('select 123 union select 456')
res.entries
#=> [["123"], ["456"]]
res.entries
#=> []
4.0:
res = my.query('select 123 union select 456')
res.entries
#=> [[123], [456]]
res.entries
#=> [[123], [456]]
FAQs
Unknown package
We found that ruby-mysql 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.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.