### Navigation

- index
- modules |
- HTSQL v2.3.3 documentation »

# Internal API

## Assorted Utilities

class `htsql.core.util.``maybe`(value_type)

  Checks if a value is either `None` or an instance of the specified type.

  Use with `isinstance()` as in:

      isinstance(X, maybe(T))

class `htsql.core.util.``oneof`(*value_types)

  Checks if a value is an instance of one of the specified types.

  Use with `isinstance()` as in:

      isinstance(X, oneof(T1, T2, ...))

class `htsql.core.util.``listof`(item_type)

  Checks if a value is a list containing elements of the specified type.

  Use with `isinstance()` as in:

      isinstance(X, listof(T))

class `htsql.core.util.``setof`(item_type)

  Checks if a value is a set containing elements of the specified type.

  Use with `isinstance()` as in:

      isinstance(X, setof(T))

class `htsql.core.util.``tupleof`(*item_types)

  Checks if a value is a tuple with the fixed number of elements of the specified types.

  Use with `isinstance()` as in:

      isinstance(X, tupleof(T1, T2, ..., TN))

class `htsql.core.util.``dictof`(key_type, item_type)

  Checks if a value is a dictionary with keys and elements of the specified types.

  Use with `isinstance()` as in:

      isinstance(X, dictof(T1, T2))

class `htsql.core.util.``omapof`(item_type)

  Checks if a value is an `omap` object with elements of the specified type.

  Use with `isinstance()` as in:

      isinstance(X, omapof(T))

class `htsql.core.util.``subclassof`(class_type)

  Checks if a value is a subclass of the specified class.

  Use with `isinstance()` as in:

      isinstance(X, subclassof(T))

class `htsql.core.util.``filelike`

  Checks if a value is a file or a file-like object.

  Usage:

      isinstance(X, filelike())

`htsql.core.util.``aresubclasses`(subclasses, superclasses)

  Takes two lists; checks if each element of the first list is a subclass of the corresponding element in the second list.

  `subclasses`: sequence of `type`
    A list of potential subclasses.
  `superclasses`: sequence of `type`
    A list of potential superclasses.
  Returns: `bool`
    `True` if the check succeeds; `False` otherwise.

`htsql.core.util.``isfinite`(value)

  Verifies that the given value is a finite number.

`htsql.core.util.``trim_doc`(doc)

  Strips indentation from a docstring; also removes leading and trailing blank lines.

  `doc`: `str` or `None`
    A docstring.

`htsql.core.util.``to_name`(text)

  Converts a string to a valid HTSQL identifier.

  The given `text` value is transformed as follows:

  - translated to Unicode normal form C;
  - converted to lowercase;
  - has non-alphanumeric characters replaced with underscores;
  - preceded with an underscore if it starts with a digit;
  - an empty string is replaced with `'_'`.

`htsql.core.util.``urlquote`(text, reserved=';/?:@&=+$, ')

  Replaces non-printable and reserved characters with `%XX` sequences.

`htsql.core.util.``to_literal`(text)

  Converts the text value to a valid string literal.

  This function escapes all non-printable characters and wraps the text value in single quotes.

`htsql.core.util.``similar`(model, sample)

  Checks if `model` is similar to `sample`.

  `model`: `unicode`
    A model string.
  `sample`: `unicode`
    A sample string.
  Returns: `bool`
    `True` if `model` is not too much different from `sample`; `False` otherwise.

  Use for error reporting to suggest alternatives for an unknown `model` identifier.

class `htsql.core.util.``TextBuffer`(text)

  Reads the input text in blocks matching some regular expressions.

  `text`: `str` or `unicode`
    The input text.
  `reset`()

    Rewinds to the beginning of the text.

  `peek`(pattern)

    Checks if the head of the buffer matches the given pattern.

    `pattern`: `str` or `unicode`
      A regular expression pattern.
    Returns: `bool`
      `True` if the buffer head matches the given pattern; `False` otherwise.
  `pull`(pattern)

    Reads a text block matching the given pattern from the head of the buffer.

    `pattern`: `str` or `unicode`
      A regular expression pattern.
    Returns: `str` or `unicode` or `None`
      A text block; `None` if the buffer head does not match the pattern.

    `pull()` skips whitespace characters and comments at the head of the buffer.

  `fail`(message)

    Generates an exception with a fragment of the buffer at the current position included in the error message.

    `message`: `str`
      The error message.

    Returns: `RuntimeError` instance

`htsql.core.util.``toposort`(elements, order, is_total=False)

  Sorts elements with respect to the given partial order.

  Takes a list of elements and a partial order relation. Returns the elements reordered to satisfy the given order.

  `elements`
    A list of elements.
  `order`
    A function which represents the partial order relation. `order(x)` takes an element `x` and produces a list of elements that must preceed `x`.
  `is_total`: `bool`
    If set, validates that the given partial order is, in fact, total.

  This function raises `RuntimeError` if `order` is not a valid partial order (contains loops) or when `is_total` is set and `order` is not a valid total order.

`htsql.core.util.``cachedproperty`

  Implements a cached property decorator.

  The decorator calls the `getter` function on the first access to the property and saves the result. Any subsequent access to the property returns the saved value.

  Usage:

      class C(object):
          @cachedproperty
          def field(self):
              # Called once to calculate the field value.
              # [...]
              return value

class `htsql.core.util.``frozenomap`(iterable=None)

  An ordered immutable mapping.

  This container behaves like an immutable `dict` object with one exception: iterating over the container produces values (rather than keys) in the order they were added to the container.

class `htsql.core.util.``omap`(iterable=None)

  An ordered mutable mapping.

  This container behaves like a `dict` object with one exception: iterating over the container produces values (rather than keys) in the order they were added to the container.

  Overriding an entry does not change its position; delete and insert the entry to move it to the end.

class `htsql.core.util.``Clonable`

  A clonable object.

  Subclasses of `Clonable` can use `clone()` and `clone_to()` methods to create a clone of the given object with a specified set of attributes replaced.

  Subclasses of `Clonable` must follow the following conventions:

  1. Clonable objects must be immutable.
  2. Each subclass must reimplement the `__init__` constructor. All arguments of `__init__` must be stored as instance attributes unchanged (or, if changed, must still be in the form acceptable by the constructor).
  3. The constructor must not expect a `*`-wildcard argument.
  4. The constructor may take a `**`-wildcard argument. In this case, the argument itself and all its entries must be stored as instance attributes.
  `clone`(**replacements)

    Clones the object assigning new values to selected attributes.

    `replacements`
      New attribute values.
    Returns
      A new object of the same type that has the same attribute values except those for which new values are specified.
  `clone_to`(clone_type, **replacements)

    Clones the object changing its type and assigning new values to selected attributes.

    `clone_type`: `type`
      The type of the new object.
    `replacements`
      New attribute values.
    Returns
      A new object of the specified type which has the same attribute values as the original object except those for which new values are provided.

class `htsql.core.util.``Hashable`

  An immutable object with by-value comparison semantics.

  A subclass of `Hashable` should reimplement `__basis__()` to produce a tuple of all object attributes which uniquely identify the object.

  Two `Hashable` instances are considered equal if they are of the same type and their basis vectors are equal.

class `htsql.core.util.``Printable`

  An object with default string representation.

  A subclass of `Printable` is expected to reimplement the `__unicode__()` method.

class `htsql.core.util.``DB`(engine, database, username=None, password=None, host=None, port=None, options=None)

  Parameters of a database connection.

  `engine`: `str`
    The type of the database server; e.g., `'pgsql'` or `'sqlite'`.
  `database`: `str`
    The name of the database; the path to the database file for SQLite.
  `username`: `str` or `None`
    The user name used for authentication; `None` to use the default.
  `password`: `str` or `None`
    The password used for authentication; `None` to authenticate without providing a password.
  `host`: `str` or `None`
    The host address; `None` to use the default or when not applicable.
  `port`: `int` or `None`
    The port number; `None` to use the default or when not applicable.
  `options`: `dict` or `None`
    A dictionary containing extra connection parameters; currently unused.
  classmethod `parse`(value)

    Parses a connection URI and returns a corresponding `DB` instance.

    `value`: `str`, `unicode`, `dict` or `DB`

    Returns: `DB`

    A connection URI is a string of the form:

        engine://username:password@host:port/database?options

    The `engine` and `database` fragments are mandatory; the others could be omitted.

    If a fragment contains separator characters which cannot be represented literally (such as `:`, `/`, `@` or `?`), the characters should be escaped using `%`-encoding.

    If the connection URI is not in a valid format, `ValueError` is raised.

    `parse()` also accepts:

    - a dictionary with keys `'engine'`, `'database'`, `'username'`, `'password'`, `'host'`, `'port'`, `'options'`;
    - an instance of `DB`.

`htsql.core.util.``autoimport`(name)

  Imports all modules (including subpackages) in a package.

  `name`: `str`
    The package name.

## Error Types

exception `htsql.core.error.``HTTPError`

  An exception as an HTTP response.

  An instance of `HTTPError` serves as a simple WSGI application generating an appropriate HTTP error code and displaying the error message.

  `status`

    HTTP status line.

exception `htsql.core.error.``BadRequestError`

  Represents `400 Bad Request`.

exception `htsql.core.error.``ForbiddenError`

  Represents `403 Forbidden`.

exception `htsql.core.error.``NotFoundError`

  Represents `404 Not Found`.

exception `htsql.core.error.``ConflictError`

  Represents `409 Conflict`.

exception `htsql.core.error.``InternalServerError`

  Represents `500 Internal Server Error`.

exception `htsql.core.error.``NotImplementedError`

  Represents `501 Not Implemented`.

exception `htsql.core.error.``EngineError`(message, quote=None)

  An error generated by the database driver.

exception `htsql.core.error.``PermissionError`(message, quote=None)

  An error caused by lack of read or write permissions.

class `htsql.core.error.``Mark`(text, start, end)

  A fragment of an HTSQL query.

  `text`: `unicode`
    The input query string.
  `start`: `int`
    The starting position of the fragment.
  `end`: `int`
    The ending position of the fragment.

  A `Mark` object represents a fragment of an HTSQL query to be used as an error context for error reporting.

  classmethod `union`(*nodes)

    Generates a new `Mark` object as a cover for a fragment collection.

    `nodes`
      A list of `Mark` instances or objects with a `mark` attribute; `None` entries are ignored.
  `excerpt`()

    Returns a list of lines that forms an excerpt of the original query string with `^` characters underlining the marked fragment.

## Syntax Parsing

The `htsql.core.syn` package defines the grammar of HTSQL and implements the HTSQL parser. Call `parse.parse()` to convert a raw query string to a syntax tree. This conversion is performed in three steps:

- Decoding: transmission artefacts are removed from the input stream of characters.
- Lexical scanning: the input stream of characters is converted to a sequence of lexical tokens.
- Syntax parsing: a sequence of lexical tokens is converted to a syntax tree.

### Data nodes

class `htsql.core.syn.token.``Token`(code, text)

  A lexical token.

  `code`: `unicode`
    The token type indicator; for operator symbols and punctuation characters, coincides with the token value. By convention, code equal to `""` indicates EOF.
  `text`: `unicode`
    The token value.

class `htsql.core.syn.syntax.``Syntax`

  A syntax node.

class `htsql.core.syn.syntax.``VoidSyntax`

  Represents a syntax node with no meaning.

  Use when a syntax node is required structurally, but no regular nodes are available.

class `htsql.core.syn.syntax.``SkipSyntax`

  A skip symbol.

      /

class `htsql.core.syn.syntax.``AssignSyntax`(larm, rarm)

  Assignment expression.

      <larm> := <rarm>

  `larm`: `SpecifySyntax`
    The left-hand side of assignment.
  `rarm`: `Syntax`
    The assigned value.

class `htsql.core.syn.syntax.``SpecifySyntax`(larms, rarms)

  Left-hand side of an assignment expression.

      <larm>
      <larm> . <larm> ...
      <larm> . <larm> ... (<rarm>, ...)

  `larms`: [`IdentifierSyntax` or `ReferenceSyntax`]
    A chain of identifiers or references separated by `.` symbol.
  `rarms`: [`IdentifierSyntax` or `ReferenceSyntax`] or `None`
    Formal parameters; `None` if no `()`.
  `identifier`: `IdentifierSyntax`
    Set only if the specifier is an identifier.
  `reference`: `ReferenceSyntax`
    Set only if the specifier is a reference.

class `htsql.core.syn.syntax.``ApplySyntax`(name, arguments)

  Function or operator application.

  This is an abstract class; concrete subclasses correspond to different syntax forms of functions and operators.

  `name`: `unicode`
    Normalized function name or operator symbol.
  `arguments`: list of `Syntax`
    Function arguments or operands of the operator.

class `htsql.core.syn.syntax.``FunctionSyntax`(identifier, arms)

  Function call notation.

      <identifier> (<arm>, ...)

  `identifier`: `IdentifierSyntax`
    The function name.
  `arms`: list of `Syntax`
    Function arguments.

class `htsql.core.syn.syntax.``PipeSyntax`(identifier, larm, rarms, is_flow, is_open)

  Pipe notation for function application.

      <larm> :<identifier>
      <larm> :<identifier> <rarm>
      <larm> :<identifier> (<rarm>, ...)
      <larm> /:<identifier> (<rarm>, ...)

  `identifier`: `IdentifierSyntax`
    The function name.
  `larm`: `Syntax`
    The first argument.
  `rarms`: [`Syntax`]
    The rest of the arguments.
  `is_flow`: `bool`
    `True` for flow (`:`), `False` for segment (`/:`) notation.
  `is_open`: `bool`
    `True` if no right-hand arguments or a single right-hand argument not enclosed in parentheses.

class `htsql.core.syn.syntax.``OperatorSyntax`(symbol, larm, rarm)

  Binary operator.

      <larm> <symbol> <rarm>

  `symbol`: `unicode`
    The operator symbol.
  `larm`: `Syntax`
    The left-hand operand.
  `rarm`: `Syntax`
    The right-hand operand.

class `htsql.core.syn.syntax.``PrefixSyntax`(symbol, arm)

  Unary operator.

      <symbol> <arm>

  `symbol`: `unicode`
    The operator symbol.
  `arm`: `Syntax`
    The operand.

class `htsql.core.syn.syntax.``FilterSyntax`(larm, rarm)

  Filtering operator.

      <larm> ? <rarm>

class `htsql.core.syn.syntax.``ProjectSyntax`(larm, rarm)

  Projection operator.

      <larm> ^ <rarm>

class `htsql.core.syn.syntax.``LinkSyntax`(larm, rarm)

  Linking operator (deprecated).

      <larm> -> <rarm>

class `htsql.core.syn.syntax.``AttachSyntax`(larm, rarm)

  Attachment operator.

      <larm> @ <rarm>

class `htsql.core.syn.syntax.``DetachSyntax`(arm)

  Detachment operator.

      @ <arm>

class `htsql.core.syn.syntax.``CollectSyntax`(arm)

  Collection operator.

      / <arm>

class `htsql.core.syn.syntax.``DirectSyntax`(symbol, arm)

  Sorting direction indicator.

      <arm> +
      <arm> -

  `symbol`: `unicode` (`'+'` or `'-'`)
    The indicator.
  `arm`: `Syntax`
    The operand.

class `htsql.core.syn.syntax.``ComposeSyntax`(larm, rarm)

  Composition expression.

      <larm> . <rarm>

  `larm`: `Syntax`
    The left-hand operand.
  `rarm`: `Syntax`
    The right-hand operand.

class `htsql.core.syn.syntax.``UnpackSyntax`(index, is_open)

  Unpacking expression.

      *
      * <index>
      * (<index>)

  `index`: `int`, `long` or `None`
    The number of the field to unpack (1-based).
  `is_open`: `bool`
    `True` if no `()`.

class `htsql.core.syn.syntax.``LiftSyntax`

  The lift symbol.

      ^

class `htsql.core.syn.syntax.``GroupSyntax`(arm)

  An expression in parentheses.

      (<arm>)

  `arm`: `Syntax`
    The expression.

class `htsql.core.syn.syntax.``SelectSyntax`(larm, rarm)

  Selection operator.

      <larm> {...}

  `larm`: `Syntax`
    The operand.
  `rarm`: `RecordSyntax`
    The selection record.

class `htsql.core.syn.syntax.``LocateSyntax`(larm, rarm)

  Location operator.

      <larm> [...]

  `larm`: `Syntax`
    The operand.
  `rarm`: `IdentitySyntax`
    The identity.

class `htsql.core.syn.syntax.``RecordSyntax`(arms)

  Record constructor.

      {<arm>, ...}

  `arms`: [`Syntax`]
    Record fields.

class `htsql.core.syn.syntax.``ListSyntax`(arms)

  List constructor.

      (<arm>, ...)

  `arms`: [`Syntax`]
    List elements.

class `htsql.core.syn.syntax.``IdentitySyntax`(arms, is_hard)

  Identity constructor.

      [<arm> . ...]
      (<arm> . ...)

  `arms`: [`Syntax`]
    Identity labels.
  `is_hard`: `bool`
    `True` for square brackets (`[]`), `False` for parentheses (`()`).

class `htsql.core.syn.syntax.``ReferenceSyntax`(identifier)

  Reference expression.

      $ <identifier>

  `identifier`: `IdentifierSyntax`
    The reference name.
  `name`: `unicode`
    Normalized identifier name.

class `htsql.core.syn.syntax.``IdentifierSyntax`(text)

  An identifier.

      <text>

  `text`: `unicode`
    The raw identifier name.
  `name`: `unicode`
    Normalized name.

class `htsql.core.syn.syntax.``LiteralSyntax`(text)

  A literal expression.

  This is an abstract class; concrete subclasses for different forms of literal expressions.

  `text`: `unicode`
    The value of the literal.

class `htsql.core.syn.syntax.``StringSyntax`(text)

  A string literal.

  A string literal is a sequence of characters enclosed in single quotes.

class `htsql.core.syn.syntax.``LabelSyntax`(text)

  A label literal.

  A label literal is a sequence of alphanumeric characters or `-` in an identity constructor.

class `htsql.core.syn.syntax.``NumberSyntax`(text, value)

  A number literal.

  `value`: `int`, `long`, `decimal.Decimal`, or `float`.
    The numeric value.

class `htsql.core.syn.syntax.``IntegerSyntax`(text)

  An integer literal.

class `htsql.core.syn.syntax.``DecimalSyntax`(text)

  A decimal literal.

  A decimal literal is a number with a decimal point.

class `htsql.core.syn.syntax.``FloatSyntax`(text)

  A float literal.

  A float literal is a number in exponential notation.

### Processes

`htsql.core.syn.decode.``decode`(text)

  Removes transmission artefacts.

  `text`: `str` or `unicode`
    A raw query string.
  Returns: `unicode`
    A processed string; ready for syntax analysis.

  `%`-encoded octets are decoded; the input text is converted to Unicode.

`htsql.core.syn.scan.``prepare_scan`(*args, **kwds)

  Returns a lexical scanner for HTSQL grammar.

`htsql.core.syn.scan.``scan`(text, start=None)

  Tokenizes the input query string.

  `text`: `str` or `unicode`
    A raw query string.
  `start`: `unicode` or `None`
    The initial lexical rule (by default, the first rule in the grammar).
  Returns: [`Token`]
    List of tokens.

`htsql.core.syn.parse.``prepare_parse`(*args, **kwds)

  Returns a syntax parser for HTSQL grammar.

`htsql.core.syn.parse.``parse`(text, start=None)

  Parses the input query string into a syntax tree.

  `text`: `str` or `unicode`
    A raw query string.
  `start`: `unicode` or `None`
    The initial production rule (by default, the first rule in the grammar).
  Returns: `Syntax`
    The corresponding syntax tree.

### Scanner and parser generators

class `htsql.core.syn.grammar.``LexicalGrammar`

  Defines a lexical grammar and generates a tokenizer.

  `add_rule`(name)

    Adds and returns a new tokenizer rule.

  `add_signal`(descriptor)

    Adds and returns a signal rule.

    A signal rule injects a signal token in front of a matched sequence of tokens.

    `descriptor`: `str`

      A string of the form:

          <name>: <pattern>

      where `<name>` is the name of a defined signal token, `<pattern>` is a regular expression for matching a sequence of tokens.

class `htsql.core.syn.grammar.``LexicalRule`(name)

  Tokenizer context for a lexical grammar.

  `add_token`(descriptor, error=None, is_junk=False, is_symbol=False, unquote=None, pop=None, push=None)

    Adds a token pattern.

    `descriptor`: `str`

      A string of the form:

          <name>: <pattern>

      where `<name>` is the token code, `<pattern>` is a regular expression for matching input characters.

    `error`: `str` or `None`
      If set, an error is raised when the token is recognized.
    `is_junk`: `bool`
      If set, the token is not emitted.
    `is_symbol`: `bool`
      If set, `<name>` is ignored and the token code is equal to the token value.
    `unquote`: `unicode` -> `unicode` or `None`
      If set, apply to the token value.
    `pop`: `int` or `None`
      If set, exit from the `pop` top tokenizer contexts.
    `push`: `unicode` or `None`
      If set, enter a new tokenizer context.

class `htsql.core.syn.grammar.``SyntaxGrammar`

  Defines a syntax grammar and generates a parser.

  `add_rule`(descriptor, match=None, fail=None)

    Adds and returns a production rule.

    `descriptor`: `str`

      A string of the form:

          <name>: <pattern>

      where `<name>` is the production name, `<pattern>` is a regular expression for matching tokens and other productions.

    `match`: `ParseStream` -> [`Syntax`]
      A function called when the rule matches a sequence of tokens. The function returns syntax nodes to replace the matched tokens.
    `fail`: (`ParseStream`, `Token`) -> exception
      A function called when the rule is unable to finish matching a sequence of tokens. The function takes a stream of nodes and a blocking token and returns an exception object.

class `htsql.core.syn.grammar.``ParseStream`(nodes)

  A buffer of `Token` and `Syntax` nodes.

  `reset`()

    Rewinds to the beginning of the buffer.

  `pull`()

    Pulls the next node from the buffer.

  `peek`(code)

    Checks if the next node is a `Token` object with the given `code`.

## Data Types

class `htsql.core.domain.``Domain`

  An HTSQL data type.

  A domain specifies the type of a value. Most HTSQL domains correspond to SQL data types, others represent HTSQL containers (record, list) or used only in special circumstances.

  A value of a specific domain could be represented in two forms:

  - as an HTSQL literal (`text`);
  - as a native Python object (`data`).

  Methods `parse()` and `dump()` translate values from one form to the other.

  static `parse`(text)

    Converts an HTSQL literal to a native Python object.

    Raises `ValueError` if the literal is not in a valid format.

    `text`: `unicode` or `None`
      An HTSQL literal representing a value of the given domain.
    Returns
      A native Python object representing the same value.
  static `dump`(data)

    Converts a native Python object to an HTSQL literal.

    `data`: (acceptable types depend on the domain)
      A native Python object representing a value of the given domain.
    Returns: `unicode` or `None`
      An HTSQL literal representing the same value.

class `htsql.core.domain.``Value`(domain, data)

  Represents data and its type.

  `domain`: `Domain`
    The data type.
  `data`
    The data value.

  Instances of `Value` are iterable and permit `len()` operator when the data type is `ListDomain`.

  In Boolean context, an instance of `Value` evaluates to `False` if and only if `data` is `None`.

class `htsql.core.domain.``Profile`(domain, **attributes)

  Describes the structure of data.

  `domain`: `Domain`
    The data type.
  `attributes`
    Extra stuctural metadata. Each entry of `attributes` becomes an attribute of the `Profile` instance.

class `htsql.core.domain.``Product`(meta, data, **attributes)

  Represents data and associated metadata.

  `meta`: `Profile`
    Structure of the data.
  `data`
    The data value.
  `attributes`
    Extra runtime metadata. Each entry of `attributes` becomes an attribute of the `Product` instance.

class `htsql.core.domain.``NullDomain`

  A domain with no values (except `null`).

  This is an abstract class.

class `htsql.core.domain.``VoidDomain`

  A domain without any valid values.

  This domain is could be used when a domain object is required structurally, but has no semantics.

class `htsql.core.domain.``EntityDomain`

  The type of class entities.

  Since class entities are not observable directly in HTSQL model, this domain does not support any values.

class `htsql.core.domain.``UntypedDomain`

  Represents a yet undetermined type.

  This domain is assigned to HTSQL literals temporarily until the actual domain could be derived from the context.

class `htsql.core.domain.``BooleanDomain`

  A Boolean data type.

  Valid literals: `'true'`, `'false'`.

  Valid native objects: `bool` values.

class `htsql.core.domain.``NumberDomain`

  A numeric data type.

  This is an abstract superclass for integer, float and decimal numbers.

  Class attributes:

  `is_exact`: `bool`
    Indicates whether the domain represents exact values.
  `radix`: `2` or `10`
    Indicates whether the values are stored in binary or decimal form.

class `htsql.core.domain.``IntegerDomain`(size=None)

  A binary integer data type.

  Valid literals: integers (in base 10) with an optional sign.

  Valid native objects: `int` or `long` values.

  `size`: `int` or `None`
    Number of bits used to store a value; `None` if not known.

class `htsql.core.domain.``FloatDomain`(size=None)

  An IEEE 754 float data type.

  Valid literals: floating-point numbers in decimal or exponential format.

  Valid native objects: `float` values.

  `size`: `int` or `None`
    Number of bits used to store a value; `None` if not known.

class `htsql.core.domain.``DecimalDomain`(precision=None, scale=None)

  An exact decimal data type.

  Valid literals: floating-point numbers in decimal or exponential format.

  Valid native objects: `decimal.Decimal` objects.

  `precision`: `int` or `None`
    Number of significant digits; `None` if infinite or not known.
  `scale`: `int` or `None`
    Number of significant digits in the fractional part; zero for integers, `None` if infinite or not known.

class `htsql.core.domain.``TextDomain`(length=None, is_varying=True)

  A text data type.

  Valid literals: any.

  Valid native object: `unicode` values; the `NUL` character is not allowed.

  `length`: `int` or `None`
    The maximum length of the value; `None` if infinite or not known.
  `is_varying`: `int`
    Indicates whether values are fixed-length or variable-length.

class `htsql.core.domain.``EnumDomain`(labels)

  An enumeration data type.

  An enumeration domain has a predefined finite set of valid text values.

  `labels`: [`unicode`]
    List of valid values.

class `htsql.core.domain.``DateDomain`

  A date data type.

  Valid literals: valid dates in the form `YYYY-MM-DD`.

  Valid native objects: `datetime.date` values.

class `htsql.core.domain.``TimeDomain`

  A time data type.

  Valid literals: valid time values in the form `HH:MM[:SS[.SSSSSS]]`.

  Valid native objects: `datetime.time` values.

class `htsql.core.domain.``DateTimeDomain`

  A date+time data type.

  Valid literals: valid date+time values in the form `YYYY-MM-DD HH:MM[:SS[.SSSSSS]]`.

  Valid native objects: `datetime.datetime` values.

class `htsql.core.domain.``OpaqueDomain`

  An unsupported SQL data type.

  This domain is used for SQL data types not supported by HTSQL.

  Valid literals: any.

  Valid native objects: any.

class `htsql.core.domain.``Record`

  A record value.

  `Record` is implemented as a tuple with named fields.

  classmethod `make`(name, fields, _cache=<WeakValueDictionary at 147700332>)

    Generates a `Record` subclass with the given fields.

    `name`: `str`, `unicode` or `None`.
      The name of the new class.
    `fields`: list of `str`, `unicode` or `None`.

      List of desired field names (`None` for a field to have no name).

      A field may get no or another name assigned if the desired field name is not available for some reason; e.g., if it is is already taked by another field or if it coincides with a Python keyword.

    Returns: subclass of `Record`
      The generated class.

class `htsql.core.domain.``ContainerDomain`

  A container type.

  This is an abstract superclass for container domains.

class `htsql.core.domain.``ListDomain`(item_domain)

  A variable-size collection of homogenous entries.

  Valid literals: quoted entries, comma-separated and wrapped in `(` and `)`.

  Valid native objects: `list` values.

  `item_domain`: `Domain`
    The type of entries.

class `htsql.core.domain.``RecordDomain`(fields)

  A fixed-size collection of heterogenous entries.

  Valid literals: quoted entries, comma-separated and wrapped in `{` and `}`.

  Valid native objects: `tuple` values.

  `fields`: [`Profile`]
    The types and other structural metadata of the record fields.

class `htsql.core.domain.``ID`

  An identity value.

  `ID` is a tuple with a string representation that produces the identity value in literal form.

  classmethod `make`(dump, _cache=<WeakValueDictionary at 147327500>)

    Generates a `ID` subclass with the given string serialization.

    `dump`
      Implementation of `unicode()` operator.
    Returns: subclass of `ID`
      The generated class.

class `htsql.core.domain.``IdentityDomain`(labels)

  A unique identifier of a database entity.

  Valid literals: identity constructors as in HTSQL grammar; outer brackets are optional and always stripped.

  Valid native objects: `tuple` values.

  `labels`: [`Domain`]
    The type of labels that form the identity value.
  `width`: `int`
    The number of leaf labels.
  `leaves`: [[`int`]]
    Paths (as tuple indexes) to leaf labels.

### Navigation

- index
- modules |
- HTSQL v2.3.3 documentation »