1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

orm: add initial pg support (#9827)

This commit is contained in:
Louis Schmieder
2021-04-25 17:57:55 +02:00
committed by GitHub
parent fc3b628440
commit 7184629969
8 changed files with 263 additions and 50 deletions

View File

@ -1,5 +1,6 @@
import sqlite
import mysql
import pg
[table: 'modules']
struct Module {
@ -46,7 +47,8 @@ fn main() {
eprintln(modul)
mysql()
// mysql()
psql()
}
fn mysql() {
@ -82,3 +84,27 @@ fn mysql() {
}
eprintln(m)
}
fn psql() {
mut db := pg.connect(host: 'localhost', user: 'test', password: 'abc', dbname: 'test') or {
panic(err)
}
mod := Module{
name: 'test'
nr_downloads: 10
creator: User{
age: 21
name: 'VUser'
is_customer: true
}
}
sql db {
create table Module
}
sql db {
insert mod into Module
}
}