|
9 | 9 | - Si vous avez besoin d'un accès admin à cette base de données (par exemple pour ajouter des extensions), les informations de connexion sont : |
10 | 10 | - Admin username : **postgres** |
11 | 11 | - Admin password : **{{ .Values.postgresql.auth.postgresPassword }}** |
| 12 | + |
| 13 | +<details> |
| 14 | + <summary>Renseigner les variables d'environment</summary> |
| 15 | + |
| 16 | +⚠️ Ces lignes ne doivent pas faire partie du code de votre projet ni être rendues publiques ⚠️ |
| 17 | + |
| 18 | +```sh |
| 19 | +export PGHOST="{{ template "common.names.fullname" . }}.{{ .Release.Namespace }}" |
| 20 | +export PGDATABASE="{{ .Values.postgresql.auth.database }}" |
| 21 | +export PGUSER="{{ .Values.postgresql.auth.username }}" |
| 22 | +export PGPASSWORD="{{ .Values.postgresql.auth.password }}" |
| 23 | +export PGPORT="{{ .Values.postgresql.service.ports.postgresql }}" |
| 24 | +``` |
| 25 | +</details> |
| 26 | + |
| 27 | +<details> |
| 28 | + <summary>Se connecter avec Python</summary> |
| 29 | + |
| 30 | +Commencer par renseigner les variables d'environment. |
| 31 | + |
| 32 | +```python |
| 33 | +import psycopg |
| 34 | +conn = psycopg.connect() |
| 35 | +with conn.cursor() as cur: |
| 36 | + print(cur.execute("SELECT version();").fetchone()) |
| 37 | +conn.close() |
| 38 | +``` |
| 39 | +</details> |
| 40 | + |
| 41 | +<details> |
| 42 | + <summary>Se connecter avec R</summary> |
| 43 | + |
| 44 | +Commencer par renseigner les variables d'environment. |
| 45 | + |
| 46 | +```r |
| 47 | +library(DBI) |
| 48 | +conn <- dbConnect(RPostgres::Postgres()) |
| 49 | +print(dbGetQuery(conn, "SELECT version();")) |
| 50 | +dbDisconnect(conn) |
| 51 | +``` |
| 52 | +</details> |
12 | 53 | {{- else }} |
13 | 54 | {{- if ne .Values.userPreferences.language "en" -}} |
14 | 55 | *NOTES are not supported for language `{{ .Values.userPreferences.language }}`... Defaulting to english.* |
|
24 | 65 | - If you need admin access to this database (e.g. to add extensions), the connection information are : |
25 | 66 | - Admin username : **postgres** |
26 | 67 | - Admin password : **{{ .Values.postgresql.auth.postgresPassword }}** |
| 68 | + |
| 69 | +<details> |
| 70 | + <summary>Setup environment variables</summary> |
| 71 | + |
| 72 | +⚠️ These lines must not be included in your project's codebase, or otherwise published ⚠️ |
| 73 | + |
| 74 | +```sh |
| 75 | +export PGHOST="{{ template "common.names.fullname" . }}.{{ .Release.Namespace }}" |
| 76 | +export PGDATABASE="{{ .Values.postgresql.auth.database }}" |
| 77 | +export PGUSER="{{ .Values.postgresql.auth.username }}" |
| 78 | +export PGPASSWORD="{{ .Values.postgresql.auth.password }}" |
| 79 | +export PGPORT="{{ .Values.postgresql.service.ports.postgresql }}" |
| 80 | +``` |
| 81 | +</details> |
| 82 | + |
| 83 | +<details> |
| 84 | + <summary>Connect with Python</summary> |
| 85 | + |
| 86 | +First set environment variables. |
| 87 | + |
| 88 | +```python |
| 89 | +import psycopg |
| 90 | +conn = psycopg.connect() |
| 91 | +with conn.cursor() as cur: |
| 92 | + print(cur.execute("SELECT version();").fetchone()) |
| 93 | +conn.close() |
| 94 | +``` |
| 95 | +</details> |
| 96 | + |
| 97 | +<details> |
| 98 | + <summary>Connect with R</summary> |
| 99 | + |
| 100 | +First set environment variables. |
| 101 | + |
| 102 | +```r |
| 103 | +library(DBI) |
| 104 | +conn <- dbConnect(RPostgres::Postgres()) |
| 105 | +print(dbGetQuery(conn, "SELECT version();")) |
| 106 | +dbDisconnect(conn) |
| 107 | +``` |
| 108 | +</details> |
27 | 109 | {{- end -}} |
0 commit comments