Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to use connection pooling #206

Open
Yakumo-Yukari opened this issue Dec 19, 2024 · 2 comments
Open

Unable to use connection pooling #206

Yakumo-Yukari opened this issue Dec 19, 2024 · 2 comments

Comments

@Yakumo-Yukari
Copy link

Yakumo-Yukari commented Dec 19, 2024

import norm/[model, sqlite, pool]
import user


proc myDb(): DbConn = open("mydb.db", "", "", "")


var connPool* = newPool[DbConn](10,myDb)

proc initDb*() =
  withDb(connPool):
    db.createTables(newUser())

proc resetPool*() =
  connPool.reset()

proc closePool*() =
  close(connPool)

error message

C:\Users\.nimble\pkgs2\norm-2.8.3-c79c7ce80ebc2264679d6a252b0250ed3b4bd867\norm\pool.nim(20, 70) Error: type mismatch: got 'None' for 'getDb' but expected 'proc (): T: DbConn{.closure.}'

@PhilippMDoerner
Copy link
Collaborator

PhilippMDoerner commented Dec 19, 2024

The nim version may be relevant here as this compiles under nim 2.0.8

import norm/[model, sqlite, pool]


proc myDb(): DbConn = open("mydb.db", "", "", "")

type User = ref object of Model
proc newUser(): User = User(id: 1)

var connPool* = newPool[DbConn](10,myDb)

proc initDb*() =
  withDb(connPool):
    db.createTables(newUser())

proc resetPool*() =
  connPool.reset()

proc closePool*() =
  close(connPool)

@Yakumo-Yukari
Copy link
Author

The nim version may be relevant here as this compiles under nim 2.0.8

Nim: 2.2.0

OS:Windows11

Can you fix it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants