activerecord-fast-import 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/activerecord-fast-import.gemspec +2 -2
- data/lib/activerecord-fast-import.rb +12 -3
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.4
|
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{activerecord-fast-import}
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.4"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Jan Suchal"]
|
12
|
-
s.date = %q{2009-
|
12
|
+
s.date = %q{2009-10-08}
|
13
13
|
s.description = %q{Native MySQL additions to ActiveRecord, like LOAD DATA INFILE, ENABLE/DISABLE KEYS, TRUNCATE TABLE.}
|
14
14
|
s.email = %q{johno@jsmf.net}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'activerecord'
|
2
|
+
|
1
3
|
module ActiveRecord #:nodoc:
|
2
4
|
class Base
|
3
5
|
# Deletes all rows in table very fast, but without calling +destroy+ method
|
@@ -16,6 +18,13 @@ module ActiveRecord #:nodoc:
|
|
16
18
|
connection.execute("ALTER TABLE #{quoted_table_name} ENABLE KEYS")
|
17
19
|
end
|
18
20
|
|
21
|
+
# Disables keys, yields block, enables keys.
|
22
|
+
def self.with_keys_disabled
|
23
|
+
disable_keys
|
24
|
+
yield
|
25
|
+
enable_keys
|
26
|
+
end
|
27
|
+
|
19
28
|
# Loads data from file using MySQL native LOAD DATA INFILE query, disabling
|
20
29
|
# key updates for even faster import speed
|
21
30
|
#
|
@@ -24,9 +33,9 @@ module ActiveRecord #:nodoc:
|
|
24
33
|
# * +options+ (see <tt>load_data_infile</tt>)
|
25
34
|
def self.fast_import(files, options = {})
|
26
35
|
files = [files] unless files.is_a? Array
|
27
|
-
|
28
|
-
|
29
|
-
|
36
|
+
with_keys_disabled do
|
37
|
+
files.each {|file| load_data_infile(file, options)}
|
38
|
+
end
|
30
39
|
end
|
31
40
|
|
32
41
|
# Loads data from file using MySQL native LOAD DATA INFILE query
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activerecord-fast-import
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jan Suchal
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-10-08 00:00:00 +02:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|