aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/sisu/v1/db_import.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/sisu/v1/db_import.rb')
-rw-r--r--lib/sisu/v1/db_import.rb46
1 files changed, 42 insertions, 4 deletions
diff --git a/lib/sisu/v1/db_import.rb b/lib/sisu/v1/db_import.rb
index da564639..7268616b 100644
--- a/lib/sisu/v1/db_import.rb
+++ b/lib/sisu/v1/db_import.rb
@@ -138,14 +138,52 @@ module SiSU_DB_import
puts @conn.driver if defined? @conn.driver
end
begin
- @conn.transaction do |conn|
- t_d.each do |sql|
- conn.execute(sql)
+ sql=''
+ if @sql_type=~/sqlite/
+ @conn.transaction do |conn|
+ t_d.each do |sql|
+ conn.execute(sql)
+ end
end
+ #also 'execute' works for sqlite
+ #@conn.execute("BEGIN")
+ # t_d.each do |sql|
+ # @conn.execute(sql)
+ # end
+ #@conn.execute("COMMIT")
+ else
+ #'do' works for postgresql
+ @conn.do("BEGIN")
+ t_d.each do |sql|
+ @conn.do(sql)
+ end
+ @conn.do("COMMIT")
+ end
+ rescue DBI::DatabaseError => e
+ puts "Error code: #{e.err}"
+ puts "Error message: #{e.errstr}"
+ puts "Error SQLSTATE: #{e.state}"
+ SiSU_Errors::Info_error.new($!,$@,@opt.cmd,@opt.fns).error
+ sqlfn="#{@env.path.sql}/#{@md.fnb}.sql"
+ sql=File.new(sqlfn,'w')
+ t_d.each {|i| sql.puts i}
+ p sqlfn
+ if @opt.cmd =~/M/
+ puts sql
+ p @conn.methods.sort
+ puts "#{__FILE__}:#{__LINE__}"
end
rescue
SiSU_Errors::Info_error.new($!,$@,@opt.cmd,@opt.fns).error
- puts "#{__FILE__}:#{__LINE__}" if @opt.cmd =~/M/
+ sqlfn="#{@env.path.sql}/#{@md.fnb}.sql"
+ sql=File.new(sqlfn,'w')
+ t_d.each {|i| sql.puts i}
+ p sqlfn
+ if @opt.cmd =~/M/
+ puts sql
+ p @conn.methods.sort
+ puts "#{__FILE__}:#{__LINE__}"
+ end
ensure
#@conn.execute("COMMIT")
end