Hello, Is there any In-Memory Database project around for Nim ? Or any wrapper available for any of these https://githubreviews.com/explore/databases/popular-in-memory ? TIA
2017-07-14 03:36:55
I dont know any of them on that list but are you aware of that you can use sqlite as in-memory database by just using ":memory:" as database name?
2017-07-14 06:00:29


nimble search XXXX

There are definately bindings for redis and several others.

2017-07-14 08:12:30
Well there are tables all in memory, just not very persistent
2017-07-14 12:36:22

There are semi-official Redis bindings here: https://github.com/nim-lang/redis

Redis would probably be my recommended approach, as it can do replication and all sorts of fancy things. The semi-official just recently got async support too.

2017-07-14 14:34:11
I've recently been working with LMDB. While it is not in memory, it is light weight and uses smart btree based memory mapping. Let me know if you want some examples of how to use it or would like to find out more. 2017-07-14 22:26:30

Thank you all !

@Stevo, can you pls provide some examples of how to use it ?

2017-07-16 13:20:07

For SQLite, have a look at the doco db_sqlite

import db_sqlite, math

let theDb = open(":memory:",nil,nil,nil)
# now do create tables, insert data, select data, ....
# using SQL (sqlite flavoured)
theDb.exec(sql"Drop table if exists myTestTbl")
theDb.exec(sql("""create table myTestTbl (
     Name  VARCHAR(50) NOT NULL,
     i     INT(11),
     f     DECIMAL(18,10))"""))

for i in 1..1000:
  theDb.exec(sql"INSERT INTO myTestTbl (name,i,f) VALUES (?,?,?)",
        "Item#" & $i, i, sqrt(i.float))

for x in theDb.fastRows(sql"select * from myTestTbl"):
  echo x


2017-07-17 00:19:21