clients.postgres #
postgres client
use hero to work with postgres
Usage: hero postgres [flags] [commands]
manage postgresql
Flags:
-help Prints help information.
-man Prints the auto-generated manpage.
Commands:
exec execute a query
check check the postgresql connection
configure configure a postgresl connection.
backup backup
print print configure info.
list list databases
configure
the postgres configuration is stored on the filesystem for further use, can be configured as follows
import freeflowuniverse.crystallib.clients.postgres
postgres.configure(name:'default',
user :'root'
port : 5432
host : 'localhost'
password : 'ssss'
dbname :'postgres')!
mut db:=postgres.get(name:'default')!
configure through heroscript
import freeflowuniverse.crystallib.clients.postgres
heroscript:='
!!postgresclient.define name:'default'
//TO IMPLEMENT
'
postgres.configure(heroscript:heroscript)!
//can also be done through get directly
mut cl:=postgres.get(reset:true,name:'default',heroscript:heroscript)
some postgresql cmds
import freeflowuniverse.crystallib.clients.postgres
mut cl:=postgres.get()! //will default get postgres client with name 'default'
cl.db_exists('mydb')!
use the good module of v
fn configure #
fn configure(instance string, cfg_ Config) !PostgresClient[Config]
fn configure_interactive #
fn configure_interactive(args_ Config, mut session base.Session) !
fn get #
fn get(instance string) !PostgresClient[Config]
fn (PostgresClient[Config]) check #
fn (mut self PostgresClient[Config]) check() !
fn (PostgresClient[Config]) exec #
fn (mut self PostgresClient[Config]) exec(c_ string) ![]pg.Row
fn (PostgresClient[Config]) db_exists #
fn (mut self PostgresClient[Config]) db_exists(name_ string) !bool
fn (PostgresClient[Config]) db_create #
fn (mut self PostgresClient[Config]) db_create(name_ string) !
fn (PostgresClient[Config]) db_delete #
fn (mut self PostgresClient[Config]) db_delete(name_ string) !
fn (PostgresClient[Config]) db_names #
fn (mut self PostgresClient[Config]) db_names() ![]string
fn (PostgresClient[Config]) backup #
fn (mut self PostgresClient[Config]) backup(args BackupParams) !
struct BackupParams #
@[params]
struct BackupParams {
pub mut:
dbname string
dest string
}
struct Config #
@[params]
struct Config {
pub mut:
instance string = 'default'
user string = 'root'
port int = 5432
host string = 'localhost'
password string
dbname string = 'postgres'
heroscript string
reset bool
}
struct PostgresClient #
struct PostgresClient[T] {
base.BaseConfig[T]
pub mut:
db pg.DB
}