mirror of
https://github.com/vlang/v.git
synced 2025-09-16 07:52:32 +03:00
examples: v back-end example for vweb (#15141)
This commit is contained in:
parent
1f3be99859
commit
2d7406a8cd
14 changed files with 378 additions and 0 deletions
18
examples/vweb_orm_jwt/src/databases/config_datases_mysql.v
Normal file
18
examples/vweb_orm_jwt/src/databases/config_datases_mysql.v
Normal file
|
@ -0,0 +1,18 @@
|
|||
module databases
|
||||
|
||||
import mysql
|
||||
import os
|
||||
|
||||
pub fn create_db_connection() ?mysql.Connection {
|
||||
mut db := mysql.Connection{
|
||||
host: os.getenv('DB_HOST')
|
||||
port: os.getenv('DB_PORT').u32()
|
||||
username: os.getenv('DB_USERNAME')
|
||||
password: os.getenv('DB_PASSWORD')
|
||||
dbname: os.getenv('DB_NAME')
|
||||
}
|
||||
|
||||
db.connect() or { println(err) }
|
||||
|
||||
return db
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue