withPool executes provided statement block in a try/finally to ensure the connection is released.
This commit is contained in:
		@@ -93,5 +93,5 @@ proc release*(pool: DbConnPool, connId: int): void =
 | 
			
		||||
 | 
			
		||||
template withConn*(pool: DbConnPool, stmt: untyped): untyped =
 | 
			
		||||
  let (connId, conn {.inject.}) = take(pool)
 | 
			
		||||
  stmt
 | 
			
		||||
  release(pool, connId)
 | 
			
		||||
  try: stmt
 | 
			
		||||
  finally: release(pool, connId)
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user