mirror of
https://github.com/vlang/v.git
synced 2025-09-13 14:32:26 +03:00
orm: add initial pg support (#9827)
This commit is contained in:
parent
fc3b628440
commit
7184629969
8 changed files with 263 additions and 50 deletions
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue