def url=(url)
      uri = URI.parse url

      case uri.scheme
      when /^mysql/
        default_port = 3306
        @engine = :mysql
      when /^postgres/
        default_port = 5432
        @engine = :postgres
      end

      raise 'Invalid database url' unless uri.user && uri.host && uri.path

      @username = uri.user
      @password = uri.password
      @hostname = uri.host
      @port     = uri.port || default_port
      @database = (uri.path || '').split('/').last
    end
def url=(url)
      uri = URI.parse url

      case uri.scheme
      when /^mysql/
        default_port = 3306
        @engine = :mysql
      when /^postgres/
        default_port = 5432
        @engine = :postgres
      end

      raise 'Invalid database url' unless uri.user && uri.host && uri.path

      @username = uri.user
      @password = uri.password
      @hostname = uri.host
      @port     = uri.port || default_port
      @database = (uri.path || '').split('/').last
    end
Handle url -> fields conversion