Initial commit
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
module CartoDB
|
||||
class ImportDatabaseConnection
|
||||
def self.connection
|
||||
@@connection ||= nil
|
||||
if @@connection
|
||||
@@connection
|
||||
else
|
||||
c = ::Sequel.connect('postgres://postgres:@localhost:5432/cartodb_importer_test')
|
||||
begin
|
||||
c.test_connection
|
||||
@@connection = c
|
||||
rescue
|
||||
c = ::Sequel.connect('postgres://postgres:@localhost:5432')
|
||||
c.run <<-SQL
|
||||
CREATE DATABASE cartodb_importer_test
|
||||
WITH TEMPLATE = template_postgis
|
||||
OWNER = postgres
|
||||
SQL
|
||||
@@connection = ::Sequel.connect('postgres://postgres:@localhost:5432/cartodb_importer_test')
|
||||
end
|
||||
return @@connection
|
||||
end
|
||||
end
|
||||
|
||||
def self.drop
|
||||
@@connection.disconnect
|
||||
@@connection = nil
|
||||
begin
|
||||
c = ::Sequel.connect('postgres://postgres:@localhost:5432')
|
||||
c.run "DROP DATABASE cartodb_importer_test"
|
||||
rescue => e
|
||||
raise e
|
||||
end
|
||||
return true
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user