<commit_before>//
//  Connection.swift
//  SQL
//
//  Created by <NAME> on 08/12/15.
//  Copyright © 2015 Formbound. All rights reserved.
//


public protocol ConnectionStringConvertible : StringLiteralConvertible, CustomStringConvertible {
    init(connectionString: String)
    
    var connectionString: String { get }
}

public class ConnectionInfo {

    public var user: String?
    public var password: String?
    public var host: String
    public var port: UInt
    public var database: String
    
    
    public init(host: String, database: String, port: UInt, user: String? = nil, password: String? = nil) {
        self.host = host
        self.database = database
        self.port = port
        self.user = user
        self.password = password
    }
}

public protocol Connection {
    
    typealias ConnectionInfoType: ConnectionInfo, StringLiteralConvertible, CustomStringConvertible
    typealias ResultType: Result
    typealias StatusType
    
    var connectionInfo: ConnectionInfoType { get }
    
    func open() throws
    
    func close()
    
    var status: StatusType { get }
    
    func execute(string: String) throws -> ResultType
    
    func begin() throws
    
    func commit() throws
    
    func rollback() throws
    
    func createSavePointNamed(name: String) throws
    
    func releaseSavePointNamed(name: String) throws
    
    func rollbackToSavePointNamed(name: String) throws
    
    init(_ connectionInfo: ConnectionInfoType)
}

public extension Connection {
    
    public func query(string: String) throws {
        try execute(string)
    }
    
    public func begin() throws {
        try execute("BEGIN")
    }
    
    public func commit() throws {
        try execute("COMMIT")
    }
    
    public func rollback() throws {
        try execute("ROLLBACK")
    }<commit_msg>Added parameter argument to Connection.execute<commit_after>//
//  Connection.swift
//  SQL
//
//  Created by <NAME> on 08/12/15.
//  Copyright © 2015 Formbound. All rights reserved.
//


public protocol ConnectionStringConvertible : StringLiteralConvertible, CustomStringConvertible {
    init(connectionString: String)
    
    var connectionString: String { get }
}

public class ConnectionInfo {

    public var user: String?
    public var password: String?
    public var host: String
    public var port: UInt
    public var database: String
    
    
    public init(host: String, database: String, port: UInt, user: String? = nil, password: String? = nil) {
        self.host = host
        self.database = database
        self.port = port
        self.user = user
        self.password = password
    }
}

public protocol Connection {
    
    typealias ConnectionInfoType: ConnectionInfo, StringLiteralConvertible, CustomStringConvertible
    typealias ResultType: Result
    typealias StatusType
    
    var connectionInfo: ConnectionInfoType { get }
    
    func open() throws
    
    func close()
    
    var status: StatusType { get }
    
    func execute(string: String) throws -> ResultType
    
    func execute(string: String, parameters: [String: CustomStringConvertible]) throws -> ResultType
    
    func begin() throws
    
    func commit() throws
    
    func rollback() throws
    
    func createSavePointNamed(name: String) throws
    
    func releaseSavePointNamed(name: String) throws
    
    func rollbackToSavePointNamed(name: String) throws
    
    init(_ connectionInfo: ConnectionInfoType)
}

public extension Connection {
    
    public func execute(string: String) throws -> ResultType {
        return try self.execute(string, parameters: [:])
    }
    
    public func begin() throws {
        try execute("BEGIN")
    }
    
    public func commit() throws {
        try execute("COMMIT")
    }
    
    public func rollback() throws {
        try execute("ROLLBACK")
    }
{'fraction_non_alphanumeric': 0.07885211995863495, 'fraction_numerical': 0.005170630816959669, 'mean_word_length': 2.5560661764705883, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '83797', 'n_tokens_mistral': 1055, 'n_tokens_neox': 1029, 'n_words': 325}