readAllSqlTables

Retrieves the schemas of all non-system tables in the database using the provided database configuration.

Default Behavior:

If DbConnectionConfig.readOnly is true (which is the default), the connection will be:

  • explicitly set as read-only via Connection.setReadOnly(true)

  • used with autoCommit = false

  • automatically rolled back after reading, ensuring no changes to the database

Even if DbConnectionConfig.readOnly is set to false, the library still prevents data-modifying queries and only permits safe SELECT operations internally.

Return

a map of String, DataFrameSchema objects representing the table name and its schema for each non-system table.

Parameters

dbConfig

the database configuration to connect to the database, including URL, user, and password.

dbType

the type of database, could be a custom object, provided by user, optional, default is null, in that case the dbType will be recognized from the dbConfig.


Retrieves the schemas of all non-system tables in the database using the provided DataSource.

Example with HikariCP:

import com.zaxxer.hikari.HikariConfig
import com.zaxxer.hikari.HikariDataSource

val config = HikariConfig().apply {
jdbcUrl = "jdbc:postgresql://localhost:5432/mydb"
username = "user"
password = "password"
}
val dataSource = HikariDataSource(config)

// Get schemas for all tables
val allSchemas = DataFrame.getSchemaForAllSqlTables(dataSource)

// Access individual table schemas
val customersSchema = allSchemas["customers"]
val ordersSchema = allSchemas["orders"]

// Iterate through all schemas
allSchemas.forEach { (tableName, schema) ->
println("Table: $tableName, Columns: ${schema.columns.keys}")
}

Return

a map of String, DataFrameSchema objects representing the table name and its schema for each non-system table.

Parameters

dataSource

the DataSource to get a database connection from.

dbType

the type of database, could be a custom object, provided by user, optional, default is null, in that case the dbType will be recognized from the dataSource.

See also


Retrieves the schemas of all non-system tables in the database using the provided database connection.

Return

a map of String, DataFrameSchema objects representing the table name and its schema for each non-system table.

Parameters

connection

the database connection.

dbType

the type of database, could be a custom object, provided by user, optional, default is null, in that case the dbType will be recognized from the connection.


fun DataFrame.Companion.readAllSqlTables(dbConfig: DbConnectionConfig, catalogue: String? = null, limit: Int? = null, inferNullability: Boolean = true, dbType: DbType? = null, configureStatement: (PreparedStatement) -> Unit = {}): Map<String, AnyFrame>

Reads all non-system tables from a database and returns them as a map of SQL tables and corresponding DataFrames using the provided database configuration and limit.

Note that if input dataframe contains duplicate column names, they will be automatically renamed in the resulting DataFrame.

Default Behavior:

If DbConnectionConfig.readOnly is true (which is the default), the connection will be:

  • explicitly set as read-only via Connection.setReadOnly(true)

  • used with autoCommit = false

  • automatically rolled back after reading, ensuring no changes to the database

Even if DbConnectionConfig.readOnly is set to false, the library still prevents data-modifying queries and only permits safe SELECT operations internally.

Return

a map of String to AnyFrame objects representing the non-system tables from the database.

Parameters

dbConfig

the database configuration to connect to the database, including URL, user, and password.

limit

the maximum number of rows to read from each table. null (default) means no limit - all available rows will be fetched or positive integer (e.g., 100) - fetch at most that many rows

catalogue

a name of the catalog from which tables will be retrieved. A null value retrieves tables from all catalogs.

inferNullability

indicates how the column nullability should be inferred.

dbType

the type of database, could be a custom object, provided by user, optional, default is null, in that case the dbType will be recognized from the dbConfig.

configureStatement

optional lambda to configure the PreparedStatement before execution. This allows for custom tuning of fetch size, query timeout, and other JDBC parameters.


fun DataFrame.Companion.readAllSqlTables(dataSource: DataSource, catalogue: String? = null, limit: Int? = null, inferNullability: Boolean = true, dbType: DbType? = null, configureStatement: (PreparedStatement) -> Unit = {}): Map<String, AnyFrame>

Reads all non-system tables from a database and returns them as a map of SQL tables and corresponding DataFrames.

Note that if input dataframe contains duplicate column names, they will be automatically renamed in the resulting DataFrame.

Example with HikariCP:

import com.zaxxer.hikari.HikariConfig
import com.zaxxer.hikari.HikariDataSource

val config = HikariConfig().apply {
jdbcUrl = "jdbc:postgresql://localhost:5432/mydb"
username = "user"
password = "password"
}
val dataSource = HikariDataSource(config)

// Read all tables from the database
val allTables = DataFrame.readAllSqlTables(dataSource, limit = 100)

// Access individual tables
val customersDF = allTables["customers"]
val ordersDF = allTables["orders"]

Return

a map of String to AnyFrame objects representing the non-system tables from the database.

Parameters

dataSource

the DataSource to get a database connection from.

catalogue

a name of the catalog from which tables will be retrieved. A null value retrieves tables from all catalogs.

limit

the maximum number of rows to read from each table. null (default) means no limit - all available rows will be fetched or positive integer (e.g., 100) - fetch at most that many rows

inferNullability

indicates how the column nullability should be inferred.

dbType

the type of database, could be a custom object, provided by user, optional, default is null, in that case the dbType will be recognized from the dataSource.

configureStatement

optional lambda to configure the PreparedStatement before execution. This allows for custom tuning of fetch size, query timeout, and other JDBC parameters.

See also


fun DataFrame.Companion.readAllSqlTables(connection: Connection, catalogue: String? = null, limit: Int? = null, inferNullability: Boolean = true, dbType: DbType? = null, configureStatement: (PreparedStatement) -> Unit = {}): Map<String, AnyFrame>

Reads all non-system tables from a database and returns them as a map of SQL tables and corresponding DataFrames.

Note that if input dataframe contains duplicate column names, they will be automatically renamed in the resulting DataFrame.

Return

a map of String to AnyFrame objects representing the non-system tables from the database.

Parameters

connection

the database connection to read tables from.

limit

the maximum number of rows to read from each table. null (default) means no limit - all available rows will be fetched or positive integer (e.g., 100) - fetch at most that many rows

catalogue

a name of the catalog from which tables will be retrieved. A null value retrieves tables from all catalogs.

inferNullability

indicates how the column nullability should be inferred.

dbType

the type of database, could be a custom object, provided by user, optional, default is null, in that case the dbType will be recognized from the connection.

configureStatement

optional lambda to configure the PreparedStatement before execution. This allows for custom tuning of fetch size, query timeout, and other JDBC parameters.

See also