Tag: mysql

在Debian Squeeze上安装mysql2 gem时出错

在Debian Squeeze上安装mysql2 gem时出现这个“流行”错误: gem install mysql2 Building native extensions. This could take a while… ERROR: Error installing mysql2: ERROR: Failed to build gem native extension. /usr/local/rvm/rubies/ruby-1.9.2-p290/bin/ruby extconf.rb checking for rb_thread_blocking_region()… yes checking for rb_wait_for_single_fd()… no checking for mysql.h… yes checking for errmsg.h… yes checking for mysqld_error.h… yes creating Makefile make gcc -I. -I/usr/local/rvm/rubies/ruby-1.9.2-p290/include/ruby-1.9.1/i686-linux -I/usr/local/rvm/rubies/ruby-1.9.2-p290/include/ruby-1.9.1/ruby/backward -I/usr/local/rvm/rubies/ruby-1.9.2-p290/include/ruby-1.9.1 […]

未初始化的常量Mysql2 :: Client :: SECURE_CONNECTION

由于mysql2发生错误,我无法运行Rails项目 这篇文章对我没有帮助: rake aborted! 未初始化的常量Mysql2 它也可以在我的同事计算机上正常工作,因此排除了项目本身的问题。 这是控制台输出: $ rails s /home/duke/.rvm/gems/ruby-2.0.0-p648/gems/bundler-1.13.6/lib/bundler/runtime.rb:94:in `rescue in block (2 levels) in require’: There was an error while trying to load the gem ‘mysql2′. (Bundler::GemRequireError) Gem Load Error is: uninitialized constant Mysql2::Client::SECURE_CONNECTION Backtrace for gem load error is: /home/duke/.rvm/gems/ruby-2.0.0-p648/gems/mysql2-0.3.14/lib/mysql2/client.rb:12:in `’ /home/duke/.rvm/gems/ruby-2.0.0-p648/gems/mysql2-0.3.14/lib/mysql2/client.rb:2:in `’ /home/duke/.rvm/gems/ruby-2.0.0-p648/gems/mysql2-0.3.14/lib/mysql2/client.rb:1:in `’ /home/duke/.rvm/gems/ruby-2.0.0-p648/gems/mysql2-0.3.14/lib/mysql2.rb:10:in `require’ /home/duke/.rvm/gems/ruby-2.0.0-p648/gems/mysql2-0.3.14/lib/mysql2.rb:10:in `’ /home/duke/.rvm/gems/ruby-2.0.0-p648/gems/bundler-1.13.6/lib/bundler/runtime.rb:91:in `require’ […]

在jruby上安装mysql的许多错误

我正在尝试安装mysql gem以便在rails上使用,使用jruby,无法想出来…任何帮助表示赞赏! $ sudo gem install mysql2 Building native extensions. This could take a while… ERROR: Error installing mysql2: ERROR: Failed to build gem native extension. /Users/masedesign/Work/repos/code/conf/vms/ruby/jruby/bin/jruby extconf.rb WARNING: JRuby does not support native extensions or the `mkmf’ library very well. Check http://kenai.com/projects/jruby/pages/Home for alternatives. checking for rb_thread_blocking_region()… checking for rb_wait_for_single_fd()… no checking for mysql.h… […]

是否有用于备份数据库中数据的rake任务?

是否有用于备份数据库中数据的rake任务? 我已经备份了我的架构,但我想备份数据。 这是一个小型的MySQL数据库。

查找涉及STI和父子关系的“重复”记录的解决方案

我有一个名为Buyable的基于STI的模型,有两个模型Basket和Item。 这里可购买的关注属性是: shop_week_id LOCATION_ID PARENT_ID 篮子和物品之间有亲子关系。 对于篮子,parent_id总是为零,但是通过引用唯一的篮子ID,项目可以属于篮子。 因此,篮子有很多物品,而物品属于一个篮子。 我需要一个篮子模型的方法: 如果表中有任何其他具有相同数量和类型的项目的篮子,则返回true。 当项目共享相同的shop_week_id和location_id时,它们被认为是相同的类型。 例如: 给出一个篮子(uid = 7)有2个项目: 项目#1 id = 3 shop_week_id = 13 location_id = 103 parent_id = 7 项目#2 id = 4 shop_week_id = 13 location_id = 204 parent_id = 7 如果表中有任何其他篮子包含正好2个项目,则返回true,其中一个项目具有shop_week_id = 13且location_id = 103,另一个项目具有shop_week_id = 13和location_id = 204.否则返回false。 你会怎么解决这个问题? 这是不言而喻的,但我正在寻找一个非常有效的解决方案。

从rails中的mysql存储过程中获取多个结果集

我一直在寻找有关这方面的提示,到目前为止还没有真正的运气。 使用mysql2 gem,尝试执行返回多个结果集的存储过程使我无法返回此上下文错误中的结果。 我发现有人建议使用mysql gem(我无法找到解释两者之间的差异以及切换时可能会遇到的内容),并且我已经有了更多的进展。 这是我到目前为止所拥有的: >> db = ActiveRecord::Base.connection.raw_connection => # >> ActiveRecord::Base.connection.select_all(“CALL p_rpt_test(”, ”);”) => [{“Header”=>”Client,Project,Type,Due Date,Assigned To”}] >> db.more_results? => true >> db.next_result Mysql::Error: Commands out of sync; you can’t run this command now from (irb):3:in `next_result’ from (irb):3 有没有人知道如何让这个工作,使用mysql2或mysqlgem? 该应用程序正在运行rails 3.0.1。

安装Mysql2 gem- 10.6服务器时出错

我正在尝试在10.6服务器上安装mysql2 gem,我收到一条错误消息,我没有看到: EBuilding native extensions. This could take a while… ERROR: Error installing mysql2: ERROR: Failed to build gem native extension. /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb checking for rb_thread_blocking_region()… no checking for mysql.h… no checking for mysql/mysql.h… no —– mysql.h is missing. please check your installation of mysql and try again. —– *** extconf.rb failed *** Could not […]

ActiveRecord :: StatementInvalid:Mysql2 :: Error:无法删除或更新父行–Rails 4.2.6

需要解决的错误: ActiveRecord :: StatementInvalid:Mysql2 :: Error:无法删除或更新父行:外键约束失败( slap_chat_development ,CONSTRAINT fk_rails_496733c195 FOREIGN KEY( group_id )REFERENCES groups ( id )):DELETE FROM groups WHERE groups 。 id = 1 问题是: 有人可以指导我从哪里修复此错误。 我看到问题在groups和chatrooms表之间的关系中持续存在。 更多详情: schema.rb ActiveRecord::Schema.define(version: 20160606100750) do create_table “chatrooms”, force: :cascade do |t| t.integer “group_id”, limit: 4 t.string “name”, limit: 255 t.datetime “created_at”, null: false t.datetime “updated_at”, null: false […]

ActiveRecord在Ruby 1.9.2-rc1下以ASCII-8Bit返回数据

除了标题之外,当从ActiveRecord加载数据时,尽管我尽最大努力强制编码,但编码始终设置为ASCII-8Bit。 我已经在这里输入了尽可能详细的信息,试图建立一个可以用来帮助我的好错误报告! 该项目使用以下技术: Padrino框架 Ruby 1.9.2-rc2(同样是1.9.1和1.9.2-preview3) ActiveRecord的 MySQL的 (完整名单) $ bundle show | ack ‘(record|padrino)’ * activerecord (2.3.8) * padrino (0.9.14) * padrino-admin (0.9.14) * padrino-core (0.9.14) * padrino-gen (0.9.14) * padrino-helpers (0.9.14) * padrino-mailer (0.9.14) 剧集表: mysql> DESCRIBE `episodes`; +—————-+————–+——+—–+———+—————-+ | Field | Type | Null | Key | Default | Extra | +—————-+————–+——+—–+———+—————-+ […]

使用SQLite与MySQL与Ruby?

我是Ruby新手并且想知道大多数人是否正在使用似乎是最自然且推荐使用Ruby的数据库的SQLLite数据库? 或者是人们使用传统的MySQL数据库? Ruby的每个好处/缺点有哪些? 谢谢,Alex