-
-
Notifications
You must be signed in to change notification settings - Fork 135
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
Meaningful error when using incorrect database url protocol #79
Comments
From the error message I guess you forgot to link the required driver on your build script, for example:
Otherwise the db do get created automatically. |
@tungd I added |
@thangngoc89 I agree that the database should be created automatically. However, in agreement with @tungd, I see that it is. For instance, I took the h-sql example and deleted If you can reproduce the original error and confirm you were linking the driver, could you say what version of sqlite3 (on the system or in esy) is installed? What versions of ocaml-sqlite3 and caqti? Maybe if something old is installed, it's possible that error codes are being interpreted incorrectly somewhere along the way. The creation of the database is kind of accidental at this point, because database init (and migrations) need a rework, and all of that might be best handled outside of Dream (though I do want to make sure it is done well, exists, and we can link to it for people to use it, and I don't mean that it is outside of the responsibility of Web library authors, just outside of the scope of Dream itself). |
I can confirm that this is error on my part. I can’t reproduce the error above |
It's likely that the original error was caused by using scheme Maybe this can be mitigated with the |
Aonther thing I just noticed is that if you declare the SQL pool but never take a connection from it, the database does not get created. This is likely to happen early in development, when first writing a handler: let () =
Dream.run
@@ Dream.logger
@@ Dream.sql_pool "sqlite3:db.sqlite"
@@ Dream.router [
Dream.get "/" (fun _ -> Dream.html "abc");
]
@@ Dream.not_found Once you call This level of laziness is part of how Dream tries to integrate transparently into larger applications without affecting them, but maybe this needs to be pointed out somewhere in the docs. |
Thank you for taking a look into this. Let’s me change the tittle of this issue |
Just adding a bit more detail on what needs to be done for the scheme sanity check. Somewhere before this call: Line 35 in 809835d
...we need to take out the Lines 43 to 46 in 809835d
suggesting that maybe the user meant We can add more sanity checks as necessary. Another thing to check is trying a connection string with no scheme at all. IIRC this generates a pretty useful error message, but it's good to check. |
I also tested what happens when there is no URI scheme (user tries to "connect to a file"): Dream.sql_pool "db.sqlite"
it's a bit verbose, but at least the Caqti error says "Missing URI scheme," so I think we can just leave that as is for now. I decided not to document automatic lazy database creation for now for two reasons:
|
Update:
This error is because incorrect database protocol was used (sqlite instead of sqlite3)
——-
Instead of this
I believe this would be the expected behavior since all of sqlite3 tools I've used do this
The text was updated successfully, but these errors were encountered: