mirror of
https://github.com/vlang/v.git
synced 2025-09-16 07:52:32 +03:00
examples: refactor vweb_orm_jwt (#15389)
This commit is contained in:
parent
9c96b13f9b
commit
b45da86688
8 changed files with 31 additions and 48 deletions
|
@ -0,0 +1,8 @@
|
|||
module databases
|
||||
|
||||
import sqlite
|
||||
|
||||
pub fn create_db_connection() ?sqlite.DB {
|
||||
mut db := sqlite.connect('database.db')?
|
||||
return db
|
||||
}
|
|
@ -1,18 +0,0 @@
|
|||
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