SQL query at server start with rocket_db_pools? #2402
-
I've got a server using SQLite with rocket_db_pools. I'd like to issue some SQL queries before the server is started (mainly CREATE TABLE IF NOT EXISTS so that my server can initialize its own schema -- ideally I'd like to create the SQLite file if doesn't exist too). Is there a way to grab a connection from a pool before or shortly after ignition? Here's what I imagine the solution might look like:
I've looked for answers that might address this, but the closest I can find is #2326. The answer there doesn't seem to involve sqlx pools or even a rocket instance. Am I the only one who wants to execute queries before the server starts? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
The database example does exactly this: https://github.com/SergioBenitez/Rocket/blob/master/examples/databases/src/sqlx.rs. |
Beta Was this translation helpful? Give feedback.
The database example does exactly this: https://github.com/SergioBenitez/Rocket/blob/master/examples/databases/src/sqlx.rs.