Where is my database stored in Slick? [Scala][Slick 3.0] -


i'm not particularly sure if valid question, wondering data base stored in slick

for example, if follow example @ http://slick.typesafe.com/doc/3.0.0/gettingstarted.html

they create tables :

// definition of suppliers table class suppliers(tag: tag) extends table[(int, string, string, string, string, string)](tag, "suppliers") {   def id = column[int]("sup_id", o.primarykey) // primary key column   def name = column[string]("sup_name")   def street = column[string]("street")   def city = column[string]("city")   def state = column[string]("state")   def zip = column[string]("zip")   // every table needs * projection same type table's type parameter   def * = (id, name, street, city, state, zip) } val suppliers = tablequery[suppliers]  // definition of coffees table class coffees(tag: tag) extends table[(string, int, double, int, int)](tag, "coffees") {   def name = column[string]("cof_name", o.primarykey)   def supid = column[int]("sup_id")   def price = column[double]("price")   def sales = column[int]("sales")   def total = column[int]("total")   def * = (name, supid, price, sales, total)   // reified foreign key relation can navigated create join   def supplier = foreignkey("sup_fk", supid, suppliers)(_.id) } val coffees = tablequery[coffees] 

and fill with

 val setup = dbio.seq(   // create tables, including primary , foreign keys   (suppliers.schema ++ coffees.schema).create,    // insert suppliers   suppliers += (101, "acme, inc.",      "99 market street", "groundsville", "ca", "95199"),   suppliers += ( 49, "superior coffee", "1 party place",    "mendocino",    "ca", "95460"),   suppliers += (150, "the high ground", "100 coffee lane",  "meadows",      "ca", "93966"),   // equivalent sql code:   // insert suppliers(sup_id, sup_name, street, city, state, zip) values (?,?,?,?,?,?)    // insert coffees (using jdbc's batch insert feature, if supported db)   coffees ++= seq(     ("colombian",         101, 7.99, 0, 0),     ("french_roast",       49, 8.99, 0, 0),     ("espresso",          150, 9.99, 0, 0),     ("colombian_decaf",   101, 8.99, 0, 0),     ("french_roast_decaf", 49, 9.99, 0, 0)   )   // equivalent sql code:   // insert coffees(cof_name, sup_id, price, sales, total) values (?,?,?,?,?) )  val setupfuture = db.run(setup) 

does database exist purely in memory?

if fill in database text file, database still exist in memory? if so, how transport disk? on right track here?

slick doesn't "store" database anywhere. slick library allows access data in database. specify database want connect using jdbc "connection url" such "jdbc:h2:mem:test1" in case. jdbc standard java api accessing relational databases, , there lot of databases out there jdbc drivers exist.

so when using slick, you're going choose database want use with: h2, postgres, mysql, oracle, sql server, etc. should consult documentation of database have chosen learn stores data.

i believe reason slick chose use h2 getting started example h2 can run in "memory mode", in data kept in memory. in mode, data purely transient , lost when program terminates. on other hand, it's easy run h2 in persistent mode data stored on disk. further, have choice of running database "embedded", or "client/server".

you should consult h2 documentation understand more (http://www.h2database.com/html/main.html). in particular, jdbc connection url gives control on whether connect transient, in-memory instance, embedded instance, or remote instance. see http://www.h2database.com/html/features.html#database_url.


Comments

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -