Module spin_sdk.wit.imports.sqlite

Expand source code
from typing import TypeVar, Generic, Union, Optional, Union, Protocol, Tuple, List, Any, Self
from enum import Flag, Enum, auto
from dataclasses import dataclass
from abc import abstractmethod
import weakref

from ..types import Result, Ok, Err, Some



@dataclass
class ErrorNoSuchDatabase:
    pass


@dataclass
class ErrorAccessDenied:
    pass


@dataclass
class ErrorInvalidConnection:
    pass


@dataclass
class ErrorDatabaseFull:
    pass


@dataclass
class ErrorIo:
    value: str


Error = Union[ErrorNoSuchDatabase, ErrorAccessDenied, ErrorInvalidConnection, ErrorDatabaseFull, ErrorIo]
"""
The set of errors which may be raised by functions in this interface
"""



@dataclass
class ValueInteger:
    value: int


@dataclass
class ValueReal:
    value: float


@dataclass
class ValueText:
    value: str


@dataclass
class ValueBlob:
    value: bytes


@dataclass
class ValueNull:
    pass


Value = Union[ValueInteger, ValueReal, ValueText, ValueBlob, ValueNull]
"""
A single column's result from a database query
"""


@dataclass
class RowResult:
    """
    A set of values for each of the columns in a query-result
    """
    values: List[Value]

@dataclass
class QueryResult:
    """
    A result of a query
    """
    columns: List[str]
    rows: List[RowResult]

class Connection:
    """
    A handle to an open sqlite instance
    """
    
    @classmethod
    def open(cls, database: str) -> Self:
        """
        Open a connection to a named database instance.
        
        If `database` is "default", the default instance is opened.
        
        `error::no-such-database` will be raised if the `name` is not recognized.
        
        Raises: `spin_sdk.wit.types.Err(spin_sdk.wit.imports.sqlite.Error)`
        """
        raise NotImplementedError

    def execute(self, statement: str, parameters: List[Value]) -> QueryResult:
        """
        Execute a statement returning back data if there is any
        
        Raises: `spin_sdk.wit.types.Err(spin_sdk.wit.imports.sqlite.Error)`
        """
        raise NotImplementedError

    def __enter__(self):
        """Returns self"""
        return self
                                                                    
    def __exit__(self, *args):
        """
        Release this resource.
        """
        raise NotImplementedError

Global variables

var Error

The set of errors which may be raised by functions in this interface

var Value

A single column's result from a database query

Classes

class Connection

A handle to an open sqlite instance

Expand source code
class Connection:
    """
    A handle to an open sqlite instance
    """
    
    @classmethod
    def open(cls, database: str) -> Self:
        """
        Open a connection to a named database instance.
        
        If `database` is "default", the default instance is opened.
        
        `error::no-such-database` will be raised if the `name` is not recognized.
        
        Raises: `spin_sdk.wit.types.Err(spin_sdk.wit.imports.sqlite.Error)`
        """
        raise NotImplementedError

    def execute(self, statement: str, parameters: List[Value]) -> QueryResult:
        """
        Execute a statement returning back data if there is any
        
        Raises: `spin_sdk.wit.types.Err(spin_sdk.wit.imports.sqlite.Error)`
        """
        raise NotImplementedError

    def __enter__(self):
        """Returns self"""
        return self
                                                                    
    def __exit__(self, *args):
        """
        Release this resource.
        """
        raise NotImplementedError

Static methods

def open(database: str) ‑> Self

Open a connection to a named database instance.

If database is "default", the default instance is opened.

error::no-such-database will be raised if the name is not recognized.

Raises: Err(Error)

Expand source code
@classmethod
def open(cls, database: str) -> Self:
    """
    Open a connection to a named database instance.
    
    If `database` is "default", the default instance is opened.
    
    `error::no-such-database` will be raised if the `name` is not recognized.
    
    Raises: `spin_sdk.wit.types.Err(spin_sdk.wit.imports.sqlite.Error)`
    """
    raise NotImplementedError

Methods

def execute(self, statement: str, parameters: List[Union[ValueIntegerValueRealValueTextValueBlobValueNull]]) ‑> QueryResult

Execute a statement returning back data if there is any

Raises: Err(Error)

Expand source code
def execute(self, statement: str, parameters: List[Value]) -> QueryResult:
    """
    Execute a statement returning back data if there is any
    
    Raises: `spin_sdk.wit.types.Err(spin_sdk.wit.imports.sqlite.Error)`
    """
    raise NotImplementedError
class ErrorAccessDenied

ErrorAccessDenied()

Expand source code
@dataclass
class ErrorAccessDenied:
    pass
class ErrorDatabaseFull

ErrorDatabaseFull()

Expand source code
@dataclass
class ErrorDatabaseFull:
    pass
class ErrorInvalidConnection

ErrorInvalidConnection()

Expand source code
@dataclass
class ErrorInvalidConnection:
    pass
class ErrorIo (value: str)

ErrorIo(value: str)

Expand source code
@dataclass
class ErrorIo:
    value: str

Class variables

var value : str
class ErrorNoSuchDatabase

ErrorNoSuchDatabase()

Expand source code
@dataclass
class ErrorNoSuchDatabase:
    pass
class QueryResult (columns: List[str], rows: List[RowResult])

A result of a query

Expand source code
@dataclass
class QueryResult:
    """
    A result of a query
    """
    columns: List[str]
    rows: List[RowResult]

Class variables

var columns : List[str]
var rows : List[RowResult]
class RowResult (values: List[Union[ValueIntegerValueRealValueTextValueBlobValueNull]])

A set of values for each of the columns in a query-result

Expand source code
@dataclass
class RowResult:
    """
    A set of values for each of the columns in a query-result
    """
    values: List[Value]

Class variables

var values : List[Union[ValueIntegerValueRealValueTextValueBlobValueNull]]
class ValueBlob (value: bytes)

ValueBlob(value: bytes)

Expand source code
@dataclass
class ValueBlob:
    value: bytes

Class variables

var value : bytes
class ValueInteger (value: int)

ValueInteger(value: int)

Expand source code
@dataclass
class ValueInteger:
    value: int

Class variables

var value : int
class ValueNull

ValueNull()

Expand source code
@dataclass
class ValueNull:
    pass
class ValueReal (value: float)

ValueReal(value: float)

Expand source code
@dataclass
class ValueReal:
    value: float

Class variables

var value : float
class ValueText (value: str)

ValueText(value: str)

Expand source code
@dataclass
class ValueText:
    value: str

Class variables

var value : str