Sqlite

class Sqlite(val customTypesMap: Map<String, SqliteCustomTypeConverter<*, *>> = emptyMap(), val customColumnsMap: Map<String, SqliteCustomTypeConverter<*, *>> = emptyMap()) : AdvancedDbType

Represents the Sqlite database type.

This class provides methods to convert data from a ResultSet to the appropriate type for Sqlite, and to generate the corresponding DataFrame schema.

Two levels of custom overrides are supported, with the following resolution order (first match wins):

  1. customColumnsMap — keyed by the column name. Use this to override a specific column, regardless of its declared type.

  2. customTypesMap — keyed by the declared SQL type name (as written in CREATE TABLE). Use this to override every column that shares a declared type.

  3. The built-in SQLite conversion for BOOLEAN, DATE, DATETIME, TIME, TIMESTAMP, DECIMAL, NUMERIC and INT. This conversion is also applied to declared types that contain one of these names as a substring. So every column with SQLite's INTEGER affinity (INT, INTEGER, TINYINT, BIGINT, …) is read as Long. A REAL or TEXT value stored in such a column is not converted: reading the table throws.

  4. The base DbType mapping.

Constructors

Link copied to clipboard
constructor(customTypesMap: Map<String, SqliteCustomTypeConverter<*, *>> = emptyMap(), customColumnsMap: Map<String, SqliteCustomTypeConverter<*, *>> = emptyMap())

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

The name of the database as specified in the JDBC URL.

Link copied to clipboard
open val defaultFetchSize: Int = 1000

Specifies the default batch size for fetching rows from the database during query execution.

Link copied to clipboard

Default mapping of Java SQL Types to KType.

Link copied to clipboard
open val defaultQueryTimeout: Int? = null

Specifies the default timeout in seconds for database queries.

Link copied to clipboard
open override val driverClassName: String

Represents the JDBC driver class name for a given database type.

Link copied to clipboard
open val tableTypes: List<String>?

The table type(s) (TABLE_TYPE) of ordinary tables in the SQL database, used by the readAllSqlTables functions as a filter when querying the database for all the tables it has using DatabaseMetaData.getTables.

Functions

Link copied to clipboard
override fun <D, P> buildDataColumn(name: String, values: List<D>, tableColumnMetadata: TableColumnMetadata, targetColumnSchema: ColumnSchema?, inferNullability: Boolean): DataColumn<P>

Builds a DataColumn from the given (preprocessed) values, adhering to targetColumnSchema.

Link copied to clipboard
open fun buildSelectTableQueryWithLimit(tableName: String, limit: Int?): String

Builds a SELECT query for reading from a table.

Link copied to clipboard
open fun buildSqlQueryWithLimit(sqlQuery: String, limit: Int = 1): String

Constructs a SQL query with a limit clause.

Link copied to clipboard
open override fun buildTableMetadata(tables: ResultSet): TableMetadata

Builds the table metadata based on the database type and the ResultSet from the query.

Link copied to clipboard

Configures the provided PreparedStatement for optimized read operations.

Link copied to clipboard
open override fun createConnection(dbConfig: DbConnectionConfig): Connection

Creates a database connection using the provided configuration. This method is only called when working with DbConnectionConfig (internally managed connections).

Link copied to clipboard
protected open override fun generateConverter(tableColumnMetadata: TableColumnMetadata): AnyJdbcToDataFrameConverter
Link copied to clipboard
protected open override fun getConverter(tableColumnMetadata: TableColumnMetadata): AnyJdbcToDataFrameConverter
Link copied to clipboard
override fun getExpectedJdbcType(tableColumnMetadata: TableColumnMetadata): KType

Returns the type of the objects returned by getValueFromResultSet for the given column. Also called type J.

Link copied to clipboard
override fun getPreprocessedValueType(tableColumnMetadata: TableColumnMetadata, expectedJdbcType: KType): KType

Returns the type of the objects returned by preprocessValue for the given column. Also called type D.

Link copied to clipboard

Retrieves column metadata from a JDBC ResultSet.

Link copied to clipboard
override fun getTargetColumnSchema(tableColumnMetadata: TableColumnMetadata, expectedValueType: KType): ColumnSchema?

Returns the target schema of the given column which buildDataColumn will adhere to. This schema corresponds to type P, in the sense that it will describe the schema of DataColumn<P>.

Link copied to clipboard
override fun <J> getValueFromResultSet(rs: ResultSet, columnIndex: Int, tableColumnMetadata: TableColumnMetadata, expectedJdbcType: KType): J

Extracts a value from the result set for the given column.

Link copied to clipboard
open override fun isSystemTable(tableMetadata: TableMetadata): Boolean

Checks if the given table name is a system table for the specified database type.

Link copied to clipboard
override fun <J, D> preprocessValue(value: J, tableColumnMetadata: TableColumnMetadata, expectedJdbcType: KType, expectedPreprocessedValueType: KType): D

(Potentially) preprocesses the value for the given column before collecting it in a DataFrame DataColumn.

Link copied to clipboard
open fun quoteIdentifier(name: String): String

Quotes an identifier (table or column name) according to database-specific rules.

Link copied to clipboard
protected fun <D, P> List<D>.toDataColumn(name: String, targetColumnSchema: ColumnSchema?, inferNullability: Boolean): DataColumn<P>

Helper function to convert this list of values to a DataColumn<P>.