Turso Platform SDK is a Kotlin library for developing applications using Turso Platform API.
The SDK covers all Platform API resources and provides statically typed classes.
Learn more about the Turso.
Checkout what libSQL can do for you at https://turso.tech/libsql.
Add package versions in gradle.properties
Example:
ktorVersion=2.3.9
dateTimeVersion=0.6.0-RC.2
logbackVersion=1.5.1
tursoSdkVersion=0.2.0 // currently published version
Add dependencies to build.gradle.kts
// define version variables
val ktorVersion: String by project
val dateTimeVersion: String by project
val logbackVersion: String by project
val tursoSdkVersion: String by project
// add maven central to repositories
repositories {
// other repositories
mavenCentral()
}
dependencies {
// ...
implementation("io.ktor:ktor-client-core:$ktorVersion")
implementation("io.ktor:ktor-client-cio:$ktorVersion")
implementation("io.ktor:ktor-client-content-negotiation:$ktorVersion")
implementation("io.ktor:ktor-serialization-kotlinx-json:$ktorVersion")
implementation("org.jetbrains.kotlinx:kotlinx-datetime-jvm:$dateTimeVersion")
implementation ("ch.qos.logback:logback-classic:$logbackVersion")
implementation("com.jeliuc:turso-sdk-jvm:$tursoSdkVersion")
// ...
}
Generate auth token. And copy it somewhere.
turso auth api-tokens mint quickstart
See official documentation.
val token = "you-api-access-token"
val client = TursoClient.using(CIO.create(), token)
Example: listing databases for an organization.
val organization = "myorg"
val databases = client.databases.list(organization)
Example: creating new database.
val createDatabase = CreateDatabase("databaseName", "databaseGroup")
val databaseCreationResponse = client.databases.create(organization, createDatabase)
Don't forget to close the client to free resources when you are done.
client.close()
For full list of examples, check tests.
- Use
kotlinx.datetime
for date and time handling - Transform into a multiplatform library (KMP) - and support JVM, JS, and Native
- HRANA3 protocol implementation (WIP)
- libSQL JDBC driver (WIP)
If you've found an error in this sample, please file an issue.
Feel free to help out by sending a pull request ❤️.
Turso and it's logo are trademarks of CHISELSTRIKE INC. All other trademarks are the property of their respective owners.
Copyright 2024 Jeliuc.com S.R.L.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0.txt
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.