def __init__(self, *args, **kwargs): super(DatabaseWrapper, self).__init__(*args, **kwargs) #======================================================================= # # if 'OPTIONS' in self.settings_dict: # self.MARS_Connection = self.settings_dict['OPTIONS'].get('MARS_Connection', False) # self.datefirst = self.settings_dict['OPTIONS'].get('datefirst', 7) # self.unicode_results = self.settings_dict['OPTIONS'].get('unicode_results', False) #======================================================================= if _DJANGO_VERSION >= 13: self.features = DatabaseFeatures(self) else: self.features = DatabaseFeatures() self.ops = DatabaseOperations(self) #======================================================================= # self.MAX_TABLE_NAME=self.ops.max_name_length() # self.MAX_INDEX_NAME=self.MAX_TABLE_NAME - 2 # self.MAX_CONSTRAINT_NAME=self.ops.max_name_length() # self.MAX_SEQNAME=self.MAX_TABLE_NAME - 3 #======================================================================= self.client = DatabaseClient(self) self.creation = DatabaseCreation(self) self.introspection = DatabaseIntrospection(self) if _DJANGO_VERSION >= 12: self.validation = BaseDatabaseValidation(self) else: self.validation = BaseDatabaseValidation() self.connection = None self.owner = None
def __init__(self, *args, **kwargs): super(DatabaseWrapper, self).__init__(*args, **kwargs) self.db_config = args[0] client_class = self.db_config['CLIENT'] client_class = import_string(client_class) self.db_name = self.db_config['NAME'] self.client = client_class(self.db_config) schema_module = self.db_config.get('SCHEMA', None) self.migrations = self.db_config.get('MIGRATIONS', False) if schema_module: self.SchemaEditorClass = import_string(schema_module + '.DatabaseSchemaEditor') self._cache = import_module(self.client.compiler_module) self.ops = DatabaseOperations(self, cache=self._cache) self.creation = DatabaseCreation(self) self.features = DatabaseFeatures(self) self.validation = BaseDatabaseValidation(self) introspection_module = self.db_config.get('INTROSPECTION', None) if introspection_module: self.introspectionClass = import_string(introspection_module + '.DatabaseIntrospection') self.introspection = self.introspectionClass(self) else: self.introspection = DatabaseIntrospection(self) logger.debug( 'Initialized django_any_backend. Compiler is %s. Client is %s.' % (self.client.compiler_module, client_class)) logger.debug('DB_config: %s' % self.db_config)
def __init__(self, *args, **kwargs): super(DatabaseWrapper, self).__init__(*args, **kwargs) options = self.settings_dict.get('OPTIONS', None) if options: self.MARS_Connection = options.get('MARS_Connection', False) self.datefirst = options.get('datefirst', 7) self.unicode_results = options.get('unicode_results', False) self.encoding = options.get('encoding', 'utf-8') self.driver_supports_utf8 = options.get('driver_supports_utf8', None) self.driver_needs_utf8 = options.get('driver_needs_utf8', None) self.limit_table_list = options.get('limit_table_list', False) # make lookup operators to be collation-sensitive if needed self.collation = options.get('collation', None) if self.collation: self.operators = dict(self.__class__.operators) ops = {} for op in self.operators: sql = self.operators[op] if sql.startswith('LIKE '): ops[op] = '%s COLLATE %s' % (sql, self.collation) self.operators.update(ops) self.test_create = self.settings_dict.get('TEST_CREATE', True) self.features = DatabaseFeatures(self) self.ops = DatabaseOperations(self) self.client = DatabaseClient(self) self.creation = DatabaseCreation(self) self.introspection = DatabaseIntrospection(self) self.validation = BaseDatabaseValidation(self) self.connection = None
def __init__(self, *args, **kwargs): self.use_transactions = kwargs.pop('use_transactions', None) super(DatabaseWrapper, self).__init__(*args, **kwargs) try: self.command_timeout = int( self.settings_dict.get('COMMAND_TIMEOUT', 30)) except ValueError: self.command_timeout = 30 options = self.settings_dict.get('OPTIONS', {}) try: self.cast_avg_to_float = not bool( options.get('disable_avg_cast', False)) except ValueError: self.cast_avg_to_float = False if 'use_legacy_date_fields' in options: warnings.warn( "The `use_legacy_date_fields` setting is no longer supported. " "If you need to use the legacy SQL 'datetime' datatype, " "you must replace them with the provided model fields.", DeprecationWarning) self.features = DatabaseFeatures(self) self.ops = DatabaseOperations(self) self.client = BaseDatabaseClient(self) self.creation = DatabaseCreation(self) self.introspection = DatabaseIntrospection(self) self.validation = BaseDatabaseValidation(self)
def __init__(self, *args, **kwargs): super(DatabaseWrapper, self).__init__(*args, **kwargs) options = self.settings_dict.get('OPTIONS', None) if options: self.encoding = options.get('encoding', 'utf-8') # make lookup operators to be collation-sensitive if needed self.collation = options.get('collation', None) if self.collation: self.operators = dict(self.__class__.operators) ops = {} for op in self.operators: sql = self.operators[op] if sql.startswith('LIKE '): ops[op] = '%s COLLATE %s' % (sql, self.collation) self.operators.update(ops) self.test_create = self.settings_dict.get('TEST_CREATE', True) self.features = DatabaseFeatures(self) self.ops = DatabaseOperations(self) self.introspection = DatabaseIntrospection(self) self.validation = BaseDatabaseValidation(self) self.creation = BaseDatabaseCreation(self) self.connection = None
def __init__(self, *args, **kwargs): super(DatabaseWrapper, self).__init__(*args, **kwargs) if 'OPTIONS' in self.settings_dict: self.datefirst = self.settings_dict['OPTIONS'].get('datefirst', 7) self.unicode_results = self.settings_dict['OPTIONS'].get('unicode_results', False) self.features = DatabaseFeatures(None) self.ops = DatabaseOperations(self) self.client = DatabaseClient(self) self.creation = DatabaseCreation(self) self.introspection = DatabaseIntrospection(self) if _DJANGO_VERSION >= 12: self.validation = BaseDatabaseValidation(self) else: self.validation = BaseDatabaseValidation() self.connection = None
def __init__(self, *args, **kwargs): super(DatabaseWrapper, self).__init__(*args, **kwargs) self.features = DatabaseFeatures(self) self.ops = DatabaseOperations(self) self.client = DatabaseClient(self) self.creation = DatabaseCreation(self) self.introspection = DatabaseIntrospection(self) self.validation = BaseDatabaseValidation(self)
def __init__(self, *args, **kwargs): super(DatabaseWrapper, self).__init__(*args, **kwargs) self.features = DatabaseFeatures(self) use_returning_into = self.settings_dict["OPTIONS"].get('use_returning_into', True) self.features.can_return_id_from_insert = use_returning_into self.ops = DatabaseOperations(self) self.client = DatabaseClient(self) self.creation = DatabaseCreation(self) self.introspection = DatabaseIntrospection(self) self.validation = BaseDatabaseValidation(self)
def __init__(self, settings_dict, alias=None, *args, **kwargs): super(DatabaseWrapper, self).__init__(settings_dict, alias=alias, *args, **kwargs) if settings_dict['HOST']: kwargs['host'] = settings_dict['HOST'] if settings_dict['PORT']: kwargs['port'] = int(settings_dict['PORT']) if 'OPTIONS' in settings_dict: kwargs.update(settings_dict['OPTIONS']) self.connection = ConnectionWrapper(**kwargs) try: self.features = DatabaseFeatures(self.connection) except TypeError: # Django < 1.3 self.features = BaseDatabaseFeatures() try: self.ops = DatabaseOperations(self.connection) except TypeError: # Django < 1.4 self.ops = DatabaseOperations() self.client = DatabaseClient(self) self.creation = DatabaseCreation(self) self.introspection = DatabaseIntrospection(self) try: self.validation = BaseDatabaseValidation(self) except TypeError: # Django < 1.2 self.validation = BaseDatabaseValidation() settings_dict['SUPPORTS_TRANSACTIONS'] = False self.settings_dict = settings_dict self.alias = alias and alias or settings_dict['DATABASE_NAME'] # transaction related attributes self.transaction_state = None
def __init__(self, *args, **kwargs): super(DatabaseWrapper, self).__init__(*args, **kwargs) opts = self.settings_dict["OPTIONS"] RC = psycopg2.extensions.ISOLATION_LEVEL_READ_COMMITTED self.isolation_level = opts.get('isolation_level', RC) self.features = DatabaseFeatures(self) self.ops = DatabaseOperations(self) self.client = DatabaseClient(self) self.creation = DatabaseCreation(self) self.introspection = DatabaseIntrospection(self) self.validation = BaseDatabaseValidation(self)
def __init__(self, *args, **kwargs): super(DatabaseWrapper, self).__init__(*args, **kwargs) # Charset used for LDAP text *values* self.charset = "utf-8" self.creation = DatabaseCreation(self) self.features = DatabaseFeatures(self) self.ops = DatabaseOperations(self) self.settings_dict['SUPPORTS_TRANSACTIONS'] = True self.autocommit = True if django.VERSION >= (1, 8): self.validation = BaseDatabaseValidation(self)
def __init__(self, *args, **kwargs): super(DatabaseWrapper, self).__init__(*args, **kwargs) if not hasattr(self, "client"): # Django 1.11 creates these automatically, when we call super # These are here for Django <= 1.10 self.features = DatabaseFeatures(self) self.ops = DatabaseOperations(self) self.client = DatabaseClient(self) self.creation = DatabaseCreation(self) self.introspection = DatabaseIntrospection(self) self.validation = BaseDatabaseValidation(self) self.autocommit = True
def __init__(self, *args, **kwargs): super(DatabaseWrapper, self).__init__(*args, **kwargs) if self.settings_dict.get('SCHEMA') and ("-c search_path="+self.settings_dict.get('SCHEMA').strip()) \ not in self.settings_dict["OPTIONS"].get("options", ""): self.settings_dict["OPTIONS"]["options"] = self.settings_dict["OPTIONS"].get("options", "") \ + " -c search_path=" \ + self.settings_dict.get('SCHEMA').strip() self.features = DatabaseFeatures(self) self.ops = DatabaseOperations(self) self.client = DatabaseClient(self) self.creation = DatabaseCreation(self) self.introspection = DatabaseIntrospection(self) self.validation = BaseDatabaseValidation(self)
def __init__(self, *args, **kwargs): super(DatabaseWrapper, self).__init__(*args, **kwargs) if not hasattr(self, "client"): # Django 1.11 creates these automatically, when we call super # These are here for Django <= 1.10 self.features = DatabaseFeatures(self) self.ops = DatabaseOperations(self) self.client = DatabaseClient(self) self.creation = DatabaseCreation(self) self.introspection = DatabaseIntrospection(self) self.validation = BaseDatabaseValidation(self) self.gcloud_project = self.settings_dict["PROJECT"] self.namespace = self.settings_dict.get("NAMESPACE") self.autocommit = True
def __init__(self, *args, **kwargs): super(DatabaseWrapper, self).__init__(*args, **kwargs) opts = self.settings_dict["OPTIONS"] # capability for multiple result sets or cursors self.supports_mars = False self.open_cursor = None # Some drivers need unicode encoded as UTF8. If this is left as # None, it will be determined based on the driver, namely it'll be # False if the driver is a windows driver and True otherwise. # # However, recent versions of FreeTDS and pyodbc (0.91 and 3.0.6 as # of writing) are perfectly okay being fed unicode, which is why # this option is configurable. if 'driver_needs_utf8' in opts: self.driver_charset = 'utf-8' else: self.driver_charset = opts.get('driver_charset', None) # data type compatibility to databases created by old django-pyodbc self.use_legacy_datetime = opts.get('use_legacy_datetime', False) # interval to wait for recovery from network error interval = opts.get('connection_recovery_interval_msec', 0.0) self.connection_recovery_interval_msec = float(interval) / 1000 # make lookup operators to be collation-sensitive if needed collation = opts.get('collation', None) if collation: self.operators = dict(self.__class__.operators) ops = {} for op in self.operators: sql = self.operators[op] if sql.startswith('LIKE '): ops[op] = '%s COLLATE %s' % (sql, collation) self.operators.update(ops) self.features = DatabaseFeatures(self) self.ops = DatabaseOperations(self) self.client = DatabaseClient(self) self.creation = DatabaseCreation(self) self.introspection = DatabaseIntrospection(self) self.validation = BaseDatabaseValidation(self)