gpt4 book ai didi

mysql - rails 大量数据在单次插入 activerecord 中发出

转载 作者:行者123 更新时间:2023-11-29 01:01:28 25 4
gpt4 key购买 nike

所以我认为大约 36,000 只是为了安全起见,我认为这个数字对于像 mysql 这样的现代 sql 数据库来说不会太大。每条记录只有两个属性。

所以我这样做:所以我将它们收集到一个插入语句中

sql = "INSERT INTO tasks (attrib_a, attrib_b) VALUES (c1,d1),(c2,d2),(c3,d3)...(c36000,d36000);"

ActiveRecord::Base.connection.execute sql

from C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/abstract_adapter.rb:219:in `log'
from C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/mysql_adapter.rb:323:in `execute_without_analyzer
from c:/r/projects/vendor/plugins/rails-footnotes/lib/rails-footnotes/notes/queries_note.rb:130:in `execute'
from C:/Ruby/lib/ruby/1.8/benchmark.rb:308:in `realtime'
from c:/r/projects/vendor/plugins/rails-footnotes/lib/rails-footnotes/notes/queries_note.rb:130:in `execute'
from (irb):53
from C:/Ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/time_or_datetime.rb:242

我不知道上面的信息是否足够,请问我这里没有提供的任何内容。那么知道这是关于什么的吗?

谢谢!!!!

最佳答案

问题是因为超时。我在使用 doctrine ORM 时遇到了同样的问题。在 php 中,我们可以通过更改 php.ini 文件中的脚本时间来解决这个问题。但我不知道如何更改 rails 中的数字。可能有人会帮助你..

关于mysql - rails 大量数据在单次插入 activerecord 中发出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2846874/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com