Scala Slick and SQLite

I am trying to create a database using Scala and SQLite. I use Slick as a library for SQLite. I have been working on the Internet for hours and still cannot figure out how to do this. I have an eclipse project with Slick installed. I am trying to create a database using

val db = Database.forUrl("url",driver = "org.SQLite.Driver") 

I have no idea what to add to the URL. I'm also not very sure about the driver part. Should I use it or does "scala.slick.driver.SQLiteDriver" work too? Or does it even matter?

I am really confused about this. Any help is appreciated

Thanks!

+5
source share
1 answer

JDBC uses drivers that implement the JDBC API, and provides access to low-level functionality for working with specific databases.

URLs are how you tell the JDBC driver which database you want to connect to. The first part of the URL is always jdbc:<driverId>: where driverId is the specific name that the driver expects to see (for example, postgresql , mysql or, in your case, sqlite .) The format of the URL after the driver-specific driver identifier drivers. With mysql and postgres, where you usually connect via TCP to the database server, you will see this format:

 jdbc:mysql://dbserver:dbport/databaseName jdbc:postgresql://dbserver:dbport/databaseName 

But since SQLite is a local in-process database, the part of the URL after the driver ID is just the path to the file system, for example:

 jdbc:sqlite:/home/me/my-db-file.sqlite 
+13
source

Source: https://habr.com/ru/post/1209786/


All Articles