Synesso
Synesso

Reputation: 38998

Scalikejdbc query results as a stream

For very large datasets, is it possible to return the results of a scalikejdbc query as a Stream? i.e. where the cursor stays open until the Stream has been exhausted so as to save on memory use? If so, how?

Upvotes: 2

Views: 1134

Answers (2)

Kazuhiro Sera
Kazuhiro Sera

Reputation: 1877

The foreach operation can help you. http://scalikejdbc.org/documentation/operations.html#foreach-operation

Upvotes: 1

piotr
piotr

Reputation: 5745

You can return your own iterator via session.toStatementExecutor but then you will have to close things manually or wrap the statements and the session in an object than then you can call close when you are done.

Upvotes: 1

Related Questions