# Path: eloquent/connectors/mysql_connector.py
# class MySqlConnector(Connector):
# 
#     RESERVED_KEYWORDS = [
#         'log_queries', 'driver', 'prefix',
#         'engine', 'charset', 'collation'
#     ]
# 
#     def connect(self, config):
#         config = dict(config.items())
#         for key, value in keys_fix.items():
#             config[value] = config[key]
#             del config[key]
# 
#         config['autocommit'] = True
#         config['cursorclass'] = cursor_class
# 
#         return self.get_api().connect(**self.get_config(config))
# 
#     def get_api(self):
#         return mysql
# 
# Path: eloquent/connectors/postgres_connector.py
# class PostgresConnector(Connector):
# 
#     def connect(self, config):
#         connection = self.get_api().connect(
#             connection_factory=psycopg2.extras.DictConnection,
#             **self.get_config(config)
#         )
#         connection.autocommit = True
# 
#         return connection
# 
#     def get_api(self):
#         return psycopg2
# 
# Path: eloquent/connectors/sqlite_connector.py
# class SQLiteConnector(Connector):
# 
#     def connect(self, config):
#         connection = self.get_api().connect(**self.get_config(config))
#         connection.isolation_level = None
#         connection.row_factory = DictCursor
# 
#         return connection
# 
#     def get_api(self):
#         return sqlite3


import random
from ..exceptions import ArgumentError
from ..exceptions.connectors import UnsupportedDriver
from .mysql_connector import MySqlConnector
from .postgres_connector import PostgresConnector
from .sqlite_connector import SQLiteConnector
from ..connections import (
    MySqlConnection,
    PostgresConnection,
    SQLiteConnection
)
# -*- coding: utf-8 -*-



class ConnectionFactory(object):

    def make(self, config, name=None):
        if 'read' in config:
            return self._create_read_write_connection(config)

        return self._create_single_connection(config)

    def _create_single_connection(self, config):
        conn = self.create_connector(config).connect(config)

        return self._create_connection(
            config['driver'],
            conn,
            config['database'],
            config.get('prefix', ''),
            config
        )


# Path: eloquent/connectors/mysql_connector.py
# class MySqlConnector(Connector):
# 
#     RESERVED_KEYWORDS = [
#         'log_queries', 'driver', 'prefix',
#         'engine', 'charset', 'collation'
#     ]
# 
#     def connect(self, config):
#         config = dict(config.items())
#         for key, value in keys_fix.items():
#             config[value] = config[key]
#             del config[key]
# 
#         config['autocommit'] = True
#         config['cursorclass'] = cursor_class
# 
#         return self.get_api().connect(**self.get_config(config))
# 
#     def get_api(self):
#         return mysql
# 
# Path: eloquent/connectors/postgres_connector.py
# class PostgresConnector(Connector):
# 
#     def connect(self, config):
#         connection = self.get_api().connect(
#             connection_factory=psycopg2.extras.DictConnection,
#             **self.get_config(config)
#         )
#         connection.autocommit = True
# 
#         return connection
# 
#     def get_api(self):
#         return psycopg2
# 
# Path: eloquent/connectors/sqlite_connector.py
# class SQLiteConnector(Connector):
# 
#     def connect(self, config):
#         connection = self.get_api().connect(**self.get_config(config))
#         connection.isolation_level = None
#         connection.row_factory = DictCursor
# 
#         return connection
# 
#     def get_api(self):
#         return sqlite3


# Path: eloquent/connectors/connection_factory.py
import random
from ..exceptions import ArgumentError
from ..exceptions.connectors import UnsupportedDriver
from .mysql_connector import MySqlConnector
from .postgres_connector import PostgresConnector
from .sqlite_connector import SQLiteConnector
from ..connections import (
    MySqlConnection,
    PostgresConnection,
    SQLiteConnection
)

# -*- coding: utf-8 -*-



class ConnectionFactory(object):

    def make(self, config, name=None):
        if 'read' in config:
            return self._create_read_write_connection(config)

        return self._create_single_connection(config)

    def _create_single_connection(self, config):
        conn = self.create_connector(config).connect(config)

        return self._create_connection(
            config['driver'],
            conn,
            config['database'],
            config.get('prefix', ''),
            config
        )


    def _create_read_write_connection(self, config):