-
Notifications
You must be signed in to change notification settings - Fork 75
Refactored DataFrame JDBC API plus DataSource handling #1487
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 5 commits
142c0eb
de3a97a
477da67
448eab6
e02a6be
7f66bf4
b53e9f1
08d927e
9f75a84
565e969
cc8c861
ecbbe53
3310382
23f7c1b
3377e98
e4e84c2
3aea719
5489889
328c46f
e007fa5
56d93f5
f0e4d69
6f2e2de
1c772a2
7009a61
f928057
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package org.jetbrains.kotlinx.dataframe.io | ||
|
||
/** | ||
* Represents the configuration for an internally managed JDBC database connection. | ||
* | ||
* This class defines connection parameters used by the library to create a `Connection` | ||
* when the user does not provide one explicitly. | ||
* It is designed for safe, read-only access by default. | ||
* | ||
* @property url The JDBC URL of the database, e.g., `"jdbc:postgresql://localhost:5432/mydb"`. | ||
* Must follow the standard format: `jdbc:subprotocol:subname`. | ||
* | ||
* @property user The username used for authentication. | ||
* Optional, default is an empty string. | ||
* | ||
* @property password The password used for authentication. | ||
* Optional, default is an empty string. | ||
* | ||
* @property readOnly If `true` (default), the library will create the connection in read-only mode. | ||
* This enables the following behavior: | ||
* - `Connection.setReadOnly(true)` | ||
* - `Connection.setAutoCommit(false)` | ||
* - automatic `rollback()` at the end of execution | ||
* | ||
* If `false`, the connection will be created with JDBC defaults (usually read-write), | ||
* but the library will still reject any queries that appear to modify data | ||
* (e.g. contain `INSERT`, `UPDATE`, `DELETE`, etc.). | ||
* | ||
* Note: Connections created using this configuration are managed entirely by the library. | ||
* Users do not have access to the underlying `Connection` instance and cannot commit or close it manually. | ||
* | ||
* ### Examples: | ||
* | ||
* ```kotlin | ||
* // Safe read-only connection (default) | ||
* val config = DbConnectionConfig("jdbc:sqlite::memory:") | ||
* val df = DataFrame.readSqlQuery(config, "SELECT * FROM books") | ||
* | ||
* // Use default JDBC connection settings (still protected against mutations) | ||
* val config = DbConnectionConfig( | ||
* url = "jdbc:sqlite::memory:", | ||
* readOnly = false | ||
* ) | ||
* ``` | ||
*/ | ||
public data class DbConnectionConfig( | ||
val url: String, | ||
val user: String = "", | ||
val password: String = "", | ||
val readOnly: Boolean = true, | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
package org.jetbrains.kotlinx.dataframe.io.db | ||
|
||
import org.jetbrains.kotlinx.dataframe.io.DbConnectionConfig | ||
import org.jetbrains.kotlinx.dataframe.io.TableColumnMetadata | ||
import org.jetbrains.kotlinx.dataframe.io.TableMetadata | ||
import org.jetbrains.kotlinx.dataframe.io.db.TableColumnMetadata | ||
|
||
import org.jetbrains.kotlinx.dataframe.io.db.TableMetadata | ||
import org.jetbrains.kotlinx.dataframe.io.getSchemaForAllSqlTables | ||
import org.jetbrains.kotlinx.dataframe.io.readAllSqlTables | ||
import org.jetbrains.kotlinx.dataframe.schema.ColumnSchema | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package org.jetbrains.kotlinx.dataframe.io.db | ||
|
||
/** | ||
* Represents a column in a database table to keep all required meta-information. | ||
* | ||
* @property [name] the name of the column. | ||
* @property [sqlTypeName] the SQL data type of the column. | ||
* @property [jdbcType] the JDBC data type of the column produced from [java.sql.Types]. | ||
* @property [size] the size of the column. | ||
* @property [javaClassName] the class name in Java. | ||
* @property [isNullable] true if column could contain nulls. | ||
*/ | ||
public data class TableColumnMetadata( | ||
zaleslaw marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
val name: String, | ||
val sqlTypeName: String, | ||
val jdbcType: Int, | ||
val size: Int, | ||
val javaClassName: String, | ||
val isNullable: Boolean = false, | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package org.jetbrains.kotlinx.dataframe.io.db | ||
|
||
/** | ||
* Represents a table metadata to store information about a database table, | ||
* including its name, schema name, and catalogue name. | ||
* | ||
* NOTE: we need to extract both, [schemaName] and [catalogue] | ||
* because the different databases have different implementations of metadata. | ||
* | ||
* @property [name] the name of the table. | ||
* @property [schemaName] the name of the schema the table belongs to (optional). | ||
* @property [catalogue] the name of the catalogue the table belongs to (optional). | ||
*/ | ||
public data class TableMetadata(val name: String, val schemaName: String?, val catalogue: String?) |
Uh oh!
There was an error while loading. Please reload this page.