@@ -13,7 +13,6 @@ import java.io.File
13
13
import java.nio.file.Files
14
14
import java.sql.Connection
15
15
import java.sql.DriverManager
16
- import java.sql.SQLException
17
16
import kotlin.reflect.typeOf
18
17
19
18
@DataSchema
@@ -50,20 +49,22 @@ interface CustomerOrderSQLite {
50
49
class SqliteTest {
51
50
companion object {
52
51
private lateinit var connection: Connection
53
- // we are using a temporary file because we need to test requests with DBConnectionConfig,
54
- // which creates a connection under the hood and need to have access to the shared SQLite database
52
+
53
+ /* *
54
+ * We are using a temporary file because we need to test requests with DBConnectionConfig,
55
+ * which creates a connection under the hood and need to have access to the shared SQLite database
56
+ */
55
57
private lateinit var testDbFile: File
56
- private lateinit var DATABASE_URL : String
58
+ private lateinit var databaseUrl : String
57
59
58
60
@BeforeClass
59
61
@JvmStatic
60
62
fun setUpClass () {
61
63
testDbFile = Files .createTempFile(" dataframe_sqlite_test_" , " .db" ).toFile()
62
64
testDbFile.deleteOnExit() // if fails
63
65
64
- DATABASE_URL = " jdbc:sqlite:${testDbFile.absolutePath} "
65
- connection = DriverManager .getConnection(DATABASE_URL )
66
-
66
+ databaseUrl = " jdbc:sqlite:${testDbFile.absolutePath} "
67
+ connection = DriverManager .getConnection(databaseUrl)
67
68
68
69
@Language(" SQL" )
69
70
val createCustomersTableQuery = """
@@ -146,7 +147,6 @@ class SqliteTest {
146
147
println (" Warning: Could not clean up test database file: ${e.message} " )
147
148
}
148
149
}
149
-
150
150
}
151
151
152
152
@Test
@@ -177,7 +177,7 @@ class SqliteTest {
177
177
fun `read from tables with DBConnectionConfig` () {
178
178
val customerTableName = " Customers"
179
179
180
- val dbConnectionConfig = DbConnectionConfig (DATABASE_URL )
180
+ val dbConnectionConfig = DbConnectionConfig (databaseUrl )
181
181
182
182
val df = DataFrame .readSqlTable(dbConnectionConfig, customerTableName).cast<CustomerSQLite >()
183
183
val result = df.filter { it[CustomerSQLite ::name] == " John Doe" }
@@ -231,7 +231,7 @@ class SqliteTest {
231
231
232
232
@Test
233
233
fun `read from sql query with DBConnectionConfig` () {
234
- val dbConnectionConfig = DbConnectionConfig (DATABASE_URL )
234
+ val dbConnectionConfig = DbConnectionConfig (databaseUrl )
235
235
236
236
val df = DataFrame .readSqlQuery(dbConnectionConfig, sqlQuery).cast<CustomerOrderSQLite >()
237
237
val result = df.filter { it[CustomerOrderSQLite ::customerSalary] > 1 }
0 commit comments