Replies: 1 comment
-
Hi @ianpurton, I'm so thrilled for Cornucopia to be featured in your website. Here's a snippet showing how to parse URLs with use std::str::FromStr;
use deadpool_postgres::Pool;
use crate::error::PoolError;
pub(crate) fn pool_from_url(url: &str) -> Result<Pool, PoolError> {
let config = tokio_postgres::Config::from_str(url)?;
let manager = deadpool_postgres::Manager::new(config, tokio_postgres::NoTls);
let pool = deadpool_postgres::Pool::builder(manager).build()?;
Ok(pool)
} I.e. Config implements I have not documented TLS capabilities extensively, since this entirely dependent and better explained by |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
So I converted my blog article into a website https://rust-on-nails.com/ and I've added cornucopia as Data Access (Option 1) https://rust-on-nails.com/docs/full-stack-web/database-access-option1/
The part that was non-trivial is when I deployed to Azure Postgres I needed TLS so you can see I had to include rustls and webpki-roots. That might be useful for your documentation as everyone will hit this when they deploy to production.
See the
create_pool
method.I also wrote some code to convert a DATABASE_URL to deadpool format. I'm not sure what most people use, but I use a database url most of the time. Maybe thats an issue for deadpool to parse URL's into a connection.
Hope this helps.
Beta Was this translation helpful? Give feedback.
All reactions