diff options
author | Jochen Topf <jochen@topf.org> | 2013-01-24 15:54:19 +0100 |
---|---|---|
committer | Jochen Topf <jochen@topf.org> | 2013-01-24 15:54:19 +0100 |
commit | 38095b40997a08a0b7e5155da442fa77165ce556 (patch) | |
tree | b46b031fad2b6a7cbff9ef11e44997455cf5f63d /sources/db | |
parent | 55550a88ff517d48ca6e56f720c4080fdb569ac9 (diff) | |
download | taginfo-38095b40997a08a0b7e5155da442fa77165ce556.tar taginfo-38095b40997a08a0b7e5155da442fa77165ce556.tar.gz |
Updated ruby import scripts
* Removed rubygems require which isn't needed any more in Ruby 1.9
* Updated transaction syntax to use blocks
* Updated copyright year
Diffstat (limited to 'sources/db')
-rwxr-xr-x | sources/db/update_characters.rb | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/sources/db/update_characters.rb b/sources/db/update_characters.rb index 671b38e..9d253d2 100755 --- a/sources/db/update_characters.rb +++ b/sources/db/update_characters.rb @@ -31,6 +31,8 @@ dir = ARGV[0] || '.' db = SQLite3::Database.new(dir + '/taginfo-db.db') db.results_as_hash = true +#------------------------------------------------------------------------------ + regexes = [ [ 'plain', %r{^[a-z]([a-z_]*[a-z])?$} ], [ 'colon', %r{^[a-z][a-z_:]*[a-z]$} ], @@ -50,11 +52,10 @@ db.execute("SELECT key FROM keys").map{ |row| row['key'] }.each do |key| end end -db.execute('BEGIN TRANSACTION'); - -keys.each do |key, type| - db.execute("UPDATE keys SET characters=? WHERE key=?", type, key); +db.transaction do |db| + keys.each do |key, type| + db.execute("UPDATE keys SET characters=? WHERE key=?", type, key); + end end -db.execute('COMMIT'); - +#-- THE END ------------------------------------------------------------------- |