Sha256: cc984cb120b9374526c30d9075e4c201533cbc6bfecf5c5debc7285920a542e0
Contents?: true
Size: 1.01 KB
Versions: 10
Compression:
Stored size: 1.01 KB
Contents
#!/usr/bin/env ruby require 'pg_graph' require 'shellopts' SPEC = " @ Demo Demonstration of reading and writing a database. Has actually nothing to do with postspec -r,reflections=EFILE @ Reflections file +i,ignore=SCHEMA Exclude the given schemas from the type model. This is required for schemas that doesn't follow PgGraph's naming convention when there is no reflections file -- DATABASE" def timeit(label = nil, &block) t0 = Time.now r = yield dt = Time.now - t0 if dt < 1 puts "#{label}: #{(1000.0 * dt).round(1)}ms" else puts "#{label}: #{dt.round(1)}s" end r end opts, args = ShellOpts.process(SPEC, ARGV) database = args.expect(1) puts "Reading and writing the given database" indent { conn = PgConn.new(database) meta = timeit("Meta") { PgMeta.new(conn) } type = timeit("Type") { PgGraph::Type.new(meta, opts.reflections, ignore: opts.ignore) } data = timeit("Read data") { PgGraph::Data.new(type, conn) } load_data = timeit("Write data") { data.write(conn) } }
Version data entries
10 entries across 10 versions & 1 rubygems