Adopted to pg-0.9.0
authorMax Lapshin <max@maxidoors.ru>
Mon, 1 Mar 2010 15:24:37 +0000 (18:24 +0300)
committerMax Lapshin <max@maxidoors.ru>
Mon, 1 Mar 2010 15:24:37 +0000 (18:24 +0300)
mysql2psql

index 7620280..12a22e0 100755 (executable)
@@ -231,6 +231,8 @@ class PostgresWriter < Writer
       "boolean"
     when "tinyblob"
       "bytea"
+    when "longblob"
+      "bytea"
     when "blob"
       "bytea"
     when "tinytext"
@@ -404,7 +406,7 @@ end
 class PostgresDbWriter < PostgresWriter
   def connection(hostname, login, password, database, port)
     database, schema = database.split(":")
-    @conn = PGconn.open(hostname, port.to_s, '', '', database, login, password)
+    @conn = PGconn.new(hostname, port.to_s, '', '', database, login, password)
     @conn.exec("SET search_path TO #{PGconn.quote_ident(schema)}") if schema
   end
   
@@ -565,7 +567,7 @@ class PostgresDbWriter < PostgresWriter
           end
         end
       end
-      @conn.putline(row.join("\t") + "\n")
+      @conn.put_copy_data(row.join("\t") + "\n")
        
       if counter != 0 && counter % 20000 == 0
         elapsedTime = Time.now - _time1
@@ -577,7 +579,7 @@ class PostgresDbWriter < PostgresWriter
       end
       
       if counter % 5000 == 0
-        @conn.endcopy
+        @conn.put_copy_end
         @conn.exec(copy_line)
       end
        
@@ -585,7 +587,7 @@ class PostgresDbWriter < PostgresWriter
     _time2 = Time.now
     puts "\n#{_counter} rows loaded in #{((_time2 - _time1) / 60).round}min #{((_time2 - _time1) % 60).round}s"
 #    @conn.putline(".\n")
-    @conn.endcopy
+    @conn.put_copy_end
   end
   
   def close