https://kotlinlang.org logo
Title
d

Dieter Konrad

03/23/2021, 9:21 AM
I want to read data from postgresql database into jupyter notebook. Is there any library for such a task in jupyter kotlin?
%use ???
a

altavir

03/23/2021, 9:37 AM
You can use any regular kotlin library to do so. Like https://github.com/JetBrains/Exposed
i

Ilya Muradyan

03/23/2021, 11:23 AM
Search for
sql
on this page gives
exposed
(and
mysql
, but it is not suitable for PostgreSQL DB)
a

altavir

03/23/2021, 11:24 AM
Oh, you already have a descriptor for
exposed
. I've missed that.
c

Carter

03/23/2021, 11:49 AM
If such a dependency exists outside of jupyter kotlin notebooks, then you can create a JSON file to describe the dependency so that you can import it. Example of how I imported uuid, datetime, and immutable collections
{
  "description": "My Dependencies",
  "properties": {
    "uuidVersion": "0.2.3",
    "kotlinxImmutableCollectionsVersion": "0.3.3",
    "kotlinxDateTimeVersion": "0.1.1"
  },
  "repositories": [
    "<https://kotlin.bintray.com/kotlin-datascience>",
    "<https://kotlin.bintray.com/kotlinx>"
  ],
  "dependencies": [
    "org.jetbrains.kotlinx:kotlinx-collections-immutable:$kotlinxImmutableCollectionsVersion",
    "com.benasher44:uuid:$uuidVersion",
    "org.jetbrains.kotlinx:kotlinx-datetime:$kotlinxDateTimeVersion"
  ]
}
%use my-dependencies@file[/data/workspace_files/my-dependencies.json]
The documentation for this leaves much to be desired.
a

altavir

03/23/2021, 11:50 AM
for such simple cases it iasier to use Repository/DependsOn/import notations in the notebook. If you need to wrap your own library I recommend to try the new Notebook Api descriptors
c

Carter

03/23/2021, 11:52 AM
i couldn’t get such syntax to work, although if you have examples to share I’m sure that would be helpful.