main
|
Last change
on this file was a4ca79c, checked in by Georgi Paunkov <paunkovgeorgi@…>, 4 days ago |
|
Initial commit
|
-
Property mode
set to
100644
|
|
File size:
624 bytes
|
| Line | |
|---|
| 1 | use sqlx::{PgPool, postgres::PgPoolOptions};
|
|---|
| 2 |
|
|---|
| 3 | pub async fn create_pool() -> PgPool {
|
|---|
| 4 | let database_url =
|
|---|
| 5 | "postgres://db_202526z_va_prj_poshoreca_owner:4040c5ddf69@localhost:9999/db_202526z_va_prj_poshoreca";
|
|---|
| 6 |
|
|---|
| 7 | PgPoolOptions::new()
|
|---|
| 8 | .max_connections(10)
|
|---|
| 9 | .after_connect(|conn, _meta| {
|
|---|
| 10 | Box::pin(async move {
|
|---|
| 11 | sqlx::query("SET search_path TO project, public")
|
|---|
| 12 | .execute(conn)
|
|---|
| 13 | .await?;
|
|---|
| 14 | Ok(())
|
|---|
| 15 | })
|
|---|
| 16 | })
|
|---|
| 17 | .connect(database_url)
|
|---|
| 18 | .await
|
|---|
| 19 | .expect("Failed to connect to PostgreSQL")
|
|---|
| 20 | } |
|---|
Note:
See
TracBrowser
for help on using the repository browser.