I want to read data from postgresql database into ...
# datascience
d
I want to read data from postgresql database into jupyter notebook. Is there any library for such a task in jupyter kotlin?
%use ???
a
You can use any regular kotlin library to do so. Like https://github.com/JetBrains/Exposed
i
Search for
sql
on this page gives
exposed
(and
mysql
, but it is not suitable for PostgreSQL DB)
a
Oh, you already have a descriptor for
exposed
. I've missed that.
c
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
Copy code
{
  "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
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
i couldn’t get such syntax to work, although if you have examples to share I’m sure that would be helpful.