I've been tempted to do something similar. The context information (e.g. environment, working directory) would be especially helpful, since that's what I'm currently missing. Have you tried https://github.com/umang1912/advanced-shell-history? That was where I planned to start.
Most of these are extremely complex for almost no good reason. Storing you bash history "in the cloud" seems like a dumb idea to me, requiring a Python script for this seems gratuitous... and essentially all of these are using PROMPT_COMMAND (except bash-history-sqlite, which seems more legit), which doesn't have the correct behavior. I remember all sorts of issues with the timing of what is logged, how pipes are handled, and interaction with expected history behavior. I'm going to counter-ask: have you tried my script? ;P I recommend starting with my script, but obviously I'm going to be biased. Almost all of my script is the actual SQL parts: you will note that I have almost no shell shenanigans. At least from the perspective of asking me why I haven't tried something else, I feel like you would have to provide some rather extreme motivation at this point to work with one of these much more complex scripts.