anorm icon indicating copy to clipboard operation
anorm copied to clipboard

Support for async database access

Open pschichtel opened this issue 5 years ago • 15 comments

I do understand that Anorm builds on top of JDBC which is inherently synchronous, just like most of the underlying drivers and protocols. However there are some databases that natively support asynchronous queries such as the postgresql and there are new database APIs like jasync-sql coming up that try to support this. I like the simplicity Anorm, but I'd also like to use the asynchronous query support of the postgresql.

Are there any plans for supporting asychronous querying?

pschichtel avatar Dec 03 '19 12:12 pschichtel

Hi, there is no such plan (and I doubt any would be able to keep Anorm simple design with such hybrid sync/async approach).

cchantep avatar Dec 03 '19 13:12 cchantep

I'm playing with the thought of forking anorm to see where I get by just replacing JDBC with e.g. jasync-sql and making the relevant APIs async. Would you that this would be feasible?

pschichtel avatar Dec 04 '19 14:12 pschichtel

There is a anorm-postgres for specific Postgres function, anyway Kotlin dependency won't be accepted for Anorm (jasync-sql).

cchantep avatar Dec 04 '19 14:12 cchantep

I don't see how I could replace anorm's query handling just in the postgresql module and this wouldn't actually be postgresql specific (even though my specific use-cases involves that db). Also jasync-sql was just the first thing that came to my mind without looking more into it. There are other projects like e.g. R2DBC that implement async DB drivers in pure Java.

pschichtel avatar Dec 04 '19 17:12 pschichtel

It's recommended to start with a specific case/DB, before thinking to generalize, to walk before running.

cchantep avatar Dec 04 '19 17:12 cchantep

Haven't worked on anything using Anorm for a while, however I helped a friend in implementing an anorm-inspired C# library, that is fully async. I might try to apply what we did there to an Anorm fork once I work on the project again, that needs this.

pschichtel avatar Jun 28 '20 15:06 pschichtel

@pschichtel have you looked at skunk project? It has similar idea with Anorm, but uses only Postgres in async way, without jdbc.

feoktant avatar Oct 11 '20 09:10 feoktant

I did not yet, but it looks interesting, thanks for the hint @feoktant

pschichtel avatar Oct 11 '20 10:10 pschichtel

You could try https://github.com/simao/anorm-async/

simao avatar Dec 29 '21 15:12 simao

@simao Please avoid the confusing name anorm-async.

cchantep avatar Dec 29 '21 16:12 cchantep

@cchantep Ok, why is it confusing?

simao avatar Dec 29 '21 16:12 simao

Even if anorm is not a registered name, naming a library not based on anorm named as anorm-* is indeed confusing.

cchantep avatar Dec 29 '21 16:12 cchantep

The second paragraph of the readme from anorm-async states:

anorm-async is a thin wrapper around anorm (...)

I have not looked at the code itself. @cchantep what makes you claim that it is in fact not based on anorm?

bursauxa avatar Jan 13 '22 16:01 bursauxa

As far as I seen, there is no anorm import the Database so I can hardly see how it could be based on Anorm.

cchantep avatar Jan 13 '22 16:01 cchantep

I have changed the name of the project. Initially I had a different idea, but I ended up implementing something different.

simao avatar Jan 20 '22 12:01 simao