sequel

【原创】大叔经验分享(43)logstash设置jdbc_default_timezone后报错

戏子无情 提交于 2020-05-04 23:52:01
logstash6.6.0-6.6.2版本使用jdbc input plugin时如果设置了jdbc_default_timezone,会报错: { 2012 rufus- scheduler intercepted an error: 2012 job: 2012 Rufus::Scheduler::CronJob " * * * * * " {} 2012 error: 2012 2012 2012 NoMethodError 2012 undefined method `utc_total_offset_rational' for # <TZInfo::TransitionsTimezonePeriod:0x78b60bbe> Did you mean? utc_total_offset 2012 /data/logstash-6.6.2/vendor/bundle/jruby/2.3.0/gems/sequel-5.17.0/lib/sequel/extensions/named_timezones.rb:81: in `convert_output_datetime_other' 2012 /data/logstash-6.6.2/vendor/bundle/jruby/2.3.0/gems/sequel-5.17.0/lib/sequel/timezones.rb:54

东软实训之数据库(2)——基本SELECT语句

我只是一个虾纸丫 提交于 2020-05-01 01:07:38
&&结构化查询语句   结构化查询语言简介   结构化查询语言(Structured Query Language)简称SQL, 是操作和检索关系型数据库的标准语言,20世纪70年代由IBM公司开发,目前应用于各种关系型数据库。   SQL的发展 1974年首次提出,当时叫SEQUEL 1980年改名为SQL 1986年,ANSI定义关系数据库语言的标准,并公布了标准SQL 1992年,通过的修改标准SQL-92 1999年,发布SQL99标准 2003年,发布   SQL2003标准。   结构化查询语言分类 结构化查询语言可分为5类: 数据查询语言(DQL:Data Query Language):语句主要包括SELECT,用于从表中检索数据。 数据操作语言(DML:Data Manipulation Language):语句主要包括INSERT,UPDATE和DELETE,用于添加,修改和删除表中的行数据。 事务处理语言(TPL:Transaction Process Language): 语句主要包括COMMIT和ROLLBACK,用于提交和回滚。 数据控制语言(DCL:Data Control Language):语句主要包括GRANT和REVOKE,用于进行授权和收回权限。 数据定义语言(DDL:Data Definition Language)

处理货币/货币的最佳方法是什么?

牧云@^-^@ 提交于 2020-03-18 21:57:31
3 月,跳不动了?>>> 我正在研究一个非常基本的购物车系统。 我有一个表 items ,其列 price 为 integer 类型。 我无法在包括欧元和美分在内的价格中显示价格值。 就Rails框架中的处理货币而言,我是否遗漏了一些明显的东西? #1楼 处理货币的常用做法是使用十进制类型。 以下是“使用Rails进行敏捷Web开发”的简单示例 add_column :products, :price, :decimal, :precision => 8, :scale => 2 这将允许您处理从-999,999.99到999,999.99的价格 您可能还希望在项目中包含验证 def validate errors.add(:price, "should be at least 0.01") if price.nil? || price < 0.01 end 理智 - 检查你的价值观。 #2楼 您可能希望在数据库中使用 DECIMAL 类型。 在迁移中,执行以下操作: # precision is the total number of digits # scale is the number of digits to the right of the decimal point add_column :items, :price, :decimal, :precision =>

create unique constraints per user

核能气质少年 提交于 2020-01-25 09:50:06
问题 I am building a small app and at this point I am creating the database schema. I use PostgreSQL with Sequel and I have the two migrations: Sequel.migration do change do Sequel::Model.db.run 'CREATE EXTENSION IF NOT EXISTS "uuid-ossp"' create_table :user do String :id, :type => :uuid, :primary_key => true, :default => Sequel.function(:uuid_generate_v4) DateTime :created_at DateTime :updated_at index :id, :unique => true end end end Sequel.migration do change do Sequel::Model.db.run 'CREATE

Unable to connect mysql from Sequel gem

丶灬走出姿态 提交于 2020-01-22 19:00:07
问题 When I try to connect to MySQL from Sequel. I am getting these errors: require 'rubygems' require 'sequel' DB = Sequel.connect(:adapter => 'mysql', :user => 'root', :host => 'localhost', :database => 'scanty',:password=>'xx') DB.tables Sequel::DatabaseConnectionError: NameError uninitialized constant Mysql::CLIENT_MULTI_RESULTS from /opt/local/lib/ruby/gems/1.8/gems/sequel-3.2.0/lib/sequel/adapters/mysql.rb:98:in `connect' from /opt/local/lib/ruby/gems/1.8/gems/sequel-3.2.0/lib/sequel

sequel never returns utf-8, just ascii-8bit

末鹿安然 提交于 2020-01-21 01:34:06
问题 There is this mysql database I'm trying to connect to. DataMapper fetches everything nicely in UTF-8 but Sequel always returns strings in ASCII-8bit which produces errors with .to_json. I have tried several things in order to get it to work. Encoding.default_external = Encoding::UTF_8 Encoding.default_internal = Encoding::UTF_8 DB.run 'set names utf8' Sequel.mysql 'db', (...), :encoding => 'utf-8' I have gems: mysql (2.9.0) (tried without), mysql2 (0.3.11) and sequel (3.42.0) The only thing

What ORM to use in one process multiple db connections sinatra application?

蹲街弑〆低调 提交于 2020-01-11 03:06:07
问题 Checked ActiveRecord, DataMapper, Sequel: some use globals (static variables) some require open db connection before loading source file with models. What ORM is better to use in sinatra application that uses different databases. 回答1: DataMapper is designed for multi-database use. You can set up multiple repositories just by saying something like DataMapper.setup(:repository_one, "mysql://localhost/my_db_name") . DataMapper then tracks all the repositories that have been setup in a hash that

Get current month with Sequel

元气小坏坏 提交于 2020-01-06 12:38:12
问题 i would like recover a list of entries for the current month with Sequel, i try: Entry.where(:date >= Date.month).sum(:duration) or Entry.where(:date.like('%/06/2013')).sum(:duration) and other ... But none of them seemed to work Thanks in advance 回答1: If you want all entries the current month and the current year, it's probably easiest to use a range: d = Date.today Entry.where(:date=> Date.new(d.year, d.month)...(Date.new(d.year, d.month) >> 1)).sum(:duration) If you want the current month

Can anyone explain why this first SQL query gives 0 when this second query gives me results

被刻印的时光 ゝ 提交于 2020-01-06 06:51:31
问题 I have two SQL queries that I thought should be equivalent: SELECT COUNT(*) FROM ( SELECT distinct(e.id) FROM entity as e join organization_feature as o on o.entity_id = e.id where exists ( select * from entity where o.feature_id = 2086 and o.string_value is not null ) and ( o.feature_id = 2038 ) GROUP BY e.id ) as res This is the first one and here is the second: SELECT COUNT(*) FROM ( SELECT distinct(e.id) FROM entity as e join organization_feature as o on o.entity_id = e.id where ( o

Sequel gem increment

瘦欲@ 提交于 2019-12-24 14:26:04
问题 I am trying to use the Ruby Sequel gem for DB operations. I am stuck for incrementing and decrementing values. The doc says that this should work, even though it seems very strange for me to be able to add a number and a symbol. 2.0.0-p247 :019 > require 'sequel' => true 2.0.0-p247 :020 > s = Sequel.connect('sqlite://db.sqlite') => #<Sequel::SQLite::Database: "sqlite://db.sqlite"> 2.0.0-p247 :021 > s[:query_volume].update_sql(:queries => 3) => "UPDATE `query_volume` SET `queries` = 3" 2.0.0