Current location

narf Source control manager Git

summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorshtrom <shtrom@1991c358-8f32-0410-a49a-990740bdf4c2>2014-04-21 14:32:27 +0000
committershtrom <shtrom@1991c358-8f32-0410-a49a-990740bdf4c2>2014-04-21 14:32:27 +0000
commit25d44d795bb924548d6586176dde9d7aee45367d (patch)
tree33b8858ca2aceaa67bec5ee513ae7f635849b553 /Blogsum2WP.rb
parent865fb53e267a1d29d36158ea5748dc7ab63e077d (diff)
[Blogsum2WP.rb] Seemingly working database connections
git-svn-id: svn+ssh://scm.narf.ssji.net/svn/shtrom/scripts@1803 1991c358-8f32-0410-a49a-990740bdf4c2
Diffstat (limited to 'Blogsum2WP.rb')
-rwxr-xr-xBlogsum2WP.rb70
1 files changed, 70 insertions, 0 deletions
diff --git a/Blogsum2WP.rb b/Blogsum2WP.rb
new file mode 100755
index 0000000..1971518
--- /dev/null
+++ b/Blogsum2WP.rb
@@ -0,0 +1,70 @@
+#!/usr/bin/env ruby19
+
+require 'rubygems'
+require 'yaml'
+require 'active_record'
+require 'sqlite3'
+require 'mysql'
+
+
+# Models generated by RMRE [0]
+# [0] https://github.com/bosko/rmre
+settings_file = './database.yml'
+# The yaml file should look like that
+#
+# blogsum:
+# adapter: sqlite3
+# database: ~/site.db
+#
+# wordpress:
+# adapter: mysql
+# encoding: utf8
+# username: wordpress
+# password:
+# database: blog
+#
+exit unless File.exists?(settings_file)
+$settings = YAML.load_file(settings_file)
+
+# Multiple database support from [1,2]
+# [1] http://jonathanng.com/ruby-on-rails/multiple-database-connections-with-rails/
+# [2] http://ilikestuffblog.com/2012/09/21/establishing-a-connection-to-a-non-default-database-in-rails-3-2-2
+class BlogsumTable < ActiveRecord::Base
+ establish_connection $settings["blogsum"]
+end
+class WordpressTable < ActiveRecord::Base
+ establish_connection $settings["wordpress"]
+end
+
+# Blogsum
+class Article < BlogsumTable
+ has_many :comments
+end
+class Comment < BlogsumTable
+end
+
+# Wordpress
+class WpComment < WordpressTable
+ self.primary_key = :comment_ID
+
+end
+class WpCommentmetum < WordpressTable
+ self.primary_key = :meta_id
+end
+class WpPost < WordpressTable
+ self.primary_key = :ID
+end
+class WpPostmetum < WordpressTable
+ self.primary_key = :meta_id
+end
+class WpTerm < WordpressTable
+ self.primary_key = :term_id
+end
+class WpTermRelationship < WordpressTable
+end
+class WpTermTaxonomy < WordpressTable
+ self.table_name = 'wp_term_taxonomy'
+ self.primary_key = :term_taxonomy_id
+end
+
+# vim: sw=2