class documentation

class DatabaseOperations(BaseDatabaseOperations):

Known subclasses: django.contrib.gis.db.backends.oracle.operations.OracleOperations

View In Hierarchy

Undocumented

Static Method convert​_empty​_bytes Undocumented
Static Method convert​_empty​_string Undocumented
Method __foreign​_key​_constraints Undocumented
Method ​_convert​_field​_to​_tz Undocumented
Method ​_get​_no​_autofield​_sequence​_name Manually created sequence name to keep backward compatibility for AutoFields that aren't Oracle identity columns.
Method ​_get​_sequence​_name Undocumented
Method ​_prepare​_tzname​_delta Undocumented
Method adapt​_datefield​_value No summary
Method adapt​_datetimefield​_value Transform a datetime value to an object compatible with what is expected by the backend driver for datetime columns.
Method adapt​_decimalfield​_value Transform a decimal.Decimal value to an object compatible with what is expected by the backend driver for decimal (numeric) columns.
Method adapt​_timefield​_value Transform a time value to an object compatible with what is expected by the backend driver for time columns.
Method bulk​_batch​_size Oracle restricts the number of parameters in a query.
Method bulk​_insert​_sql Undocumented
Method cache​_key​_culling​_sql Return an SQL query that retrieves the first cache key greater than the n smallest.
Method combine​_expression No summary
Method conditional​_expression​_supported​_in​_where​_clause Oracle supports only EXISTS(...) or filters in the WHERE clause, others must be compared with True.
Method convert​_binaryfield​_value Undocumented
Method convert​_booleanfield​_value Undocumented
Method convert​_datefield​_value Undocumented
Method convert​_datetimefield​_value Undocumented
Method convert​_textfield​_value Undocumented
Method convert​_timefield​_value Undocumented
Method convert​_uuidfield​_value Undocumented
Method date​_extract​_sql Given a lookup_type of 'year', 'month', or 'day', return the SQL that extracts a value from the given date field field_name.
Method date​_trunc​_sql Given a lookup_type of 'year', 'month', or 'day', return the SQL that truncates the given date or datetime field field_name to a date object with only the given specificity.
Method datetime​_cast​_date​_sql Return the SQL to cast a datetime value to date value.
Method datetime​_cast​_time​_sql Return the SQL to cast a datetime value to time value.
Method datetime​_extract​_sql Given a lookup_type of 'year', 'month', 'day', 'hour', 'minute', or 'second', return the SQL that extracts a value from the given datetime field field_name.
Method datetime​_trunc​_sql Given a lookup_type of 'year', 'month', 'day', 'hour', 'minute', or 'second', return the SQL that truncates the given datetime field field_name to a datetime object with only the given specificity.
Method deferrable​_sql Return the SQL to make a constraint "initially deferred" during a CREATE TABLE statement.
Method fetch​_returned​_insert​_columns Given a cursor object that has just performed an INSERT...RETURNING statement into a table, return the newly created data.
Method field​_cast​_sql No summary
Method get​_db​_converters Return a list of functions needed to convert field data.
Method last​_executed​_query Return a string of the query last executed by the given cursor, with placeholders replaced with actual values.
Method last​_insert​_id Given a cursor object that has just performed an INSERT statement into a table that has an auto-incrementing ID, return the newly created ID.
Method limit​_offset​_sql Return LIMIT/OFFSET SQL clause.
Method lookup​_cast Return the string to use in a query when performing lookups ("contains", "like", etc.). It should contain a '%s' placeholder for the column being searched against.
Method max​_in​_list​_size Return the maximum number of items that can be passed in a single 'IN' list condition, or None if the backend does not impose a limit.
Method max​_name​_length Return the maximum length of table and column names, or None if there is no limit.
Method no​_limit​_value Return the value to use for the LIMIT when we are wanting "LIMIT infinity". Return None if the limit clause can be omitted in this case.
Method pk​_default​_value Return the value to use during an INSERT statement to specify that the field should use its default value.
Method prep​_for​_iexact​_query Undocumented
Method process​_clob Return the value of a CLOB column, for backends that return a locator object that requires additional processing.
Method quote​_name Return a quoted version of the given table, index, or column name. Do not quote the given name if it's already been quoted.
Method regex​_lookup Return the string to use in a query when performing regular expression lookups (using "regex" or "iregex"). It should contain a '%s' placeholder for the column being searched against.
Method return​_insert​_columns For backends that support returning columns as part of an insert query, return the SQL and params to append to the INSERT query. The returned fragment should contain a format string to hold the appropriate column.
Method sequence​_reset​_by​_name​_sql Return a list of the SQL statements required to reset sequences passed in sequences.
Method sequence​_reset​_sql Return a list of the SQL statements required to reset sequences for the given models.
Method sql​_flush Return a list of SQL statements required to remove all data from the given database tables (without actually removing the tables themselves).
Method start​_transaction​_sql Return the SQL statement required to start a transaction.
Method subtract​_temporals Undocumented
Method tablespace​_sql Return the SQL that will be used in a query to define the tablespace.
Method time​_trunc​_sql Given a lookup_type of 'hour', 'minute' or 'second', return the SQL that truncates the given time or datetime field field_name to a time object with only the given specificity.
Class Variable ​_sequence​_reset​_sql Undocumented
Class Variable ​_tzname​_re Undocumented
Class Variable cast​_char​_field​_without​_max​_length Undocumented
Class Variable cast​_data​_types Undocumented
Class Variable integer​_field​_ranges Undocumented
Class Variable set​_operators Undocumented
Property ​_foreign​_key​_constraints Undocumented

Inherited from BaseDatabaseOperations:

Constant CURRENT​_ROW Undocumented
Constant FOLLOWING Undocumented
Constant PRECEDING Undocumented
Constant UNBOUNDED​_FOLLOWING Undocumented
Constant UNBOUNDED​_PRECEDING Undocumented
Method __init__ Undocumented
Method ​_get​_limit​_offset​_params Undocumented
Method adapt​_ipaddressfield​_value Transform a string representation of an IP address into the expected type for the backend driver.
Method adapt​_unknown​_value Transform a value to something compatible with the backend driver.
Method autoinc​_sql Return any SQL needed to support auto-incrementing primary keys, or None if no SQL is necessary.
Method binary​_placeholder​_sql Some backends require special syntax to insert binary content (MySQL for example uses '_binary %s').
Method check​_expression​_support Check that the backend supports the provided expression.
Method combine​_duration​_expression Undocumented
Method compiler Return the SQLCompiler class corresponding to the given name, in the namespace corresponding to the compiler_module attribute on this backend.
Method convert​_durationfield​_value Undocumented
Method distinct​_sql Return an SQL DISTINCT clause which removes duplicate rows from the result set. If any fields are given, only check the given fields for duplicates.
Method end​_transaction​_sql Return the SQL statement required to end a transaction.
Method execute​_sql​_flush Execute a list of SQL statements to flush the database.
Method explain​_query​_prefix Undocumented
Method for​_update​_sql Return the FOR UPDATE SQL clause to lock rows for an update operation.
Method force​_no​_ordering Return a list used in the "ORDER BY" clause to force no ordering at all. Return an empty list to include nothing in the ordering.
Method ignore​_conflicts​_suffix​_sql Undocumented
Method insert​_statement Undocumented
Method integer​_field​_range Given an integer field internal type (e.g. 'PositiveIntegerField'), return a tuple of the (min_value, max_value) form representing the range of the column type bound to the field.
Method modify​_insert​_params Allow modification of insert parameters. Needed for Oracle Spatial backend due to #10888.
Method prep​_for​_like​_query Prepare a value for use in a LIKE query.
Method prepare​_sql​_script Take an SQL script that may contain multiple lines and return a list of statements to feed to successive cursor.execute() calls.
Method savepoint​_commit​_sql Return the SQL for committing the given savepoint.
Method savepoint​_create​_sql Return the SQL for starting a new savepoint. Only required if the "uses_savepoints" feature is True. The "sid" parameter is a string for the savepoint id.
Method savepoint​_rollback​_sql Return the SQL for rolling back the given savepoint.
Method set​_time​_zone​_sql Return the SQL that will set the connection's time zone.
Method time​_extract​_sql Given a lookup_type of 'hour', 'minute', or 'second', return the SQL that extracts a value from the given time field field_name.
Method unification​_cast​_sql Given a field instance, return the SQL that casts the result of a union to that type. The resulting string should contain a '%s' placeholder for the expression being cast.
Method validate​_autopk​_value Certain backends do not accept some values for "serial" fields (for example zero in MySQL). Raise a ValueError if the value is invalid, otherwise return the validated value.
Method window​_frame​_end Undocumented
Method window​_frame​_range​_start​_end Undocumented
Method window​_frame​_rows​_start​_end Return SQL for start and end points in an OVER clause window frame.
Method window​_frame​_start Undocumented
Method year​_lookup​_bounds​_for​_date​_field Return a two-elements list with the lower and upper bound to be used with a BETWEEN operator to query a DateField value using a year lookup.
Method year​_lookup​_bounds​_for​_datetime​_field Return a two-elements list with the lower and upper bound to be used with a BETWEEN operator to query a DateTimeField value using a year lookup.
Class Variable compiler​_module Undocumented
Class Variable explain​_prefix Undocumented
Instance Variable ​_cache Undocumented
Instance Variable connection Undocumented
@staticmethod
def convert_empty_bytes(value, expression, connection):

Undocumented

@staticmethod
def convert_empty_string(value, expression, connection):

Undocumented

def __foreign_key_constraints(self, table_name, recursive):

Undocumented

def _convert_field_to_tz(self, field_name, tzname):

Undocumented

def _get_no_autofield_sequence_name(self, table):
Manually created sequence name to keep backward compatibility for AutoFields that aren't Oracle identity columns.
def _get_sequence_name(self, cursor, table, pk_name):

Undocumented

def _prepare_tzname_delta(self, tzname):

Undocumented

def adapt_datefield_value(self, value):
Transform a date value to an object compatible with what is expected by the backend driver for date columns. The default implementation transforms the date to text, but that is not necessary for Oracle.
def adapt_datetimefield_value(self, value):

Transform a datetime value to an object compatible with what is expected by the backend driver for datetime columns.

If naive datetime is passed assumes that is in UTC. Normally Django models.DateTimeField makes sure that if USE_TZ is True passed datetime is timezone aware.

def adapt_decimalfield_value(self, value, max_digits=None, decimal_places=None):
Transform a decimal.Decimal value to an object compatible with what is expected by the backend driver for decimal (numeric) columns.
def adapt_timefield_value(self, value):
Transform a time value to an object compatible with what is expected by the backend driver for time columns.
def bulk_batch_size(self, fields, objs):
Oracle restricts the number of parameters in a query.
def bulk_insert_sql(self, fields, placeholder_rows):

Undocumented

def cache_key_culling_sql(self):

Return an SQL query that retrieves the first cache key greater than the n smallest.

This is used by the 'db' cache backend to determine where to start culling.

def combine_expression(self, connector, sub_expressions):
Combine a list of subexpressions into a single expression, using the provided connecting operator. This is required because operators can vary between backends (e.g., Oracle with %% and &) and between subexpression types (e.g., date expressions).
def conditional_expression_supported_in_where_clause(self, expression):
Oracle supports only EXISTS(...) or filters in the WHERE clause, others must be compared with True.
def convert_binaryfield_value(self, value, expression, connection):

Undocumented

def convert_booleanfield_value(self, value, expression, connection):

Undocumented

def convert_datefield_value(self, value, expression, connection):

Undocumented

def convert_datetimefield_value(self, value, expression, connection):

Undocumented

def convert_textfield_value(self, value, expression, connection):

Undocumented

def convert_timefield_value(self, value, expression, connection):

Undocumented

def convert_uuidfield_value(self, value, expression, connection):

Undocumented

def date_extract_sql(self, lookup_type, field_name):
Given a lookup_type of 'year', 'month', or 'day', return the SQL that extracts a value from the given date field field_name.
def date_trunc_sql(self, lookup_type, field_name, tzname=None):

Given a lookup_type of 'year', 'month', or 'day', return the SQL that truncates the given date or datetime field field_name to a date object with only the given specificity.

If tzname is provided, the given value is truncated in a specific timezone.

def datetime_cast_date_sql(self, field_name, tzname):
Return the SQL to cast a datetime value to date value.
def datetime_cast_time_sql(self, field_name, tzname):
Return the SQL to cast a datetime value to time value.
def datetime_extract_sql(self, lookup_type, field_name, tzname):
Given a lookup_type of 'year', 'month', 'day', 'hour', 'minute', or 'second', return the SQL that extracts a value from the given datetime field field_name.
def datetime_trunc_sql(self, lookup_type, field_name, tzname):
Given a lookup_type of 'year', 'month', 'day', 'hour', 'minute', or 'second', return the SQL that truncates the given datetime field field_name to a datetime object with only the given specificity.
def deferrable_sql(self):
Return the SQL to make a constraint "initially deferred" during a CREATE TABLE statement.
def fetch_returned_insert_columns(self, cursor, returning_params):
Given a cursor object that has just performed an INSERT...RETURNING statement into a table, return the newly created data.
def field_cast_sql(self, db_type, internal_type):
Given a column type (e.g. 'BLOB', 'VARCHAR') and an internal type (e.g. 'GenericIPAddressField'), return the SQL to cast it before using it in a WHERE statement. The resulting string should contain a '%s' placeholder for the column being searched against.
def get_db_converters(self, expression):

Return a list of functions needed to convert field data.

Some field types on some backends do not provide data in the correct format, this is the hook for converter functions.

def last_executed_query(self, cursor, sql, params):

Return a string of the query last executed by the given cursor, with placeholders replaced with actual values.

sql is the raw query containing placeholders and params is the sequence of parameters. These are used by default, but this method exists for database backends to provide a better implementation according to their own quoting schemes.

def last_insert_id(self, cursor, table_name, pk_name):

Given a cursor object that has just performed an INSERT statement into a table that has an auto-incrementing ID, return the newly created ID.

pk_name is the name of the primary-key column.

def limit_offset_sql(self, low_mark, high_mark):
def lookup_cast(self, lookup_type, internal_type=None):
Return the string to use in a query when performing lookups ("contains", "like", etc.). It should contain a '%s' placeholder for the column being searched against.
def max_in_list_size(self):
Return the maximum number of items that can be passed in a single 'IN' list condition, or None if the backend does not impose a limit.
def max_name_length(self):
Return the maximum length of table and column names, or None if there is no limit.
def no_limit_value(self):
Return the value to use for the LIMIT when we are wanting "LIMIT infinity". Return None if the limit clause can be omitted in this case.
def pk_default_value(self):
Return the value to use during an INSERT statement to specify that the field should use its default value.
def prep_for_iexact_query(self, x):

Undocumented

def process_clob(self, value):
Return the value of a CLOB column, for backends that return a locator object that requires additional processing.
def quote_name(self, name):
Return a quoted version of the given table, index, or column name. Do not quote the given name if it's already been quoted.
def regex_lookup(self, lookup_type):

Return the string to use in a query when performing regular expression lookups (using "regex" or "iregex"). It should contain a '%s' placeholder for the column being searched against.

If the feature is not supported (or part of it is not supported), raise NotImplementedError.

def return_insert_columns(self, fields):
For backends that support returning columns as part of an insert query, return the SQL and params to append to the INSERT query. The returned fragment should contain a format string to hold the appropriate column.
def sequence_reset_by_name_sql(self, style, sequences):

Return a list of the SQL statements required to reset sequences passed in sequences.

The style argument is a Style object as returned by either color_style() or no_style() in django.core.management.color.

def sequence_reset_sql(self, style, model_list):

Return a list of the SQL statements required to reset sequences for the given models.

The style argument is a Style object as returned by either color_style() or no_style() in django.core.management.color.

def sql_flush(self, style, tables, *, reset_sequences=False, allow_cascade=False):

Return a list of SQL statements required to remove all data from the given database tables (without actually removing the tables themselves).

The style argument is a Style object as returned by either color_style() or no_style() in django.core.management.color.

If reset_sequences is True, the list includes SQL statements required to reset the sequences.

The allow_cascade argument determines whether truncation may cascade to tables with foreign keys pointing the tables being truncated. PostgreSQL requires a cascade even if these tables are empty.

def start_transaction_sql(self):
Return the SQL statement required to start a transaction.
def subtract_temporals(self, internal_type, lhs, rhs):
def tablespace_sql(self, tablespace, inline=False):

Return the SQL that will be used in a query to define the tablespace.

Return '' if the backend doesn't support tablespaces.

If inline is True, append the SQL to a row; otherwise append it to the entire CREATE TABLE or CREATE INDEX statement.

def time_trunc_sql(self, lookup_type, field_name, tzname=None):

Given a lookup_type of 'hour', 'minute' or 'second', return the SQL that truncates the given time or datetime field field_name to a time object with only the given specificity.

If tzname is provided, the given value is truncated in a specific timezone.

_sequence_reset_sql: str =

Undocumented

_tzname_re =

Undocumented

cast_char_field_without_max_length: str =
@cached_property
_foreign_key_constraints =

Undocumented