comparison src/luan/host/Util.luan @ 1626:cf9dfead83a3

use Config.postgres
author Franklin Schmidt <fschmidt@gmail.com>
date Tue, 07 Dec 2021 18:30:02 -0700
parents f67f972bd648
children 07be5015159d
comparison
equal deleted inserted replaced
1625:57c8baadb357 1626:cf9dfead83a3
32 local file = Io.schemes.file(dir.."/info.luan") 32 local file = Io.schemes.file(dir.."/info.luan")
33 file.delete() 33 file.delete()
34 file.write_text("return "..stringify{password=password}.."\n") 34 file.write_text("return "..stringify{password=password}.."\n")
35 end 35 end
36 36
37 local pg_admin = Package.load("file:postgres.luan") 37 local Config = require "file:Config.luan"
38 local pg_admin = Config.postgres
38 39
39 function Util.set_postgres_password(domain,password) 40 function Util.set_postgres_password(domain,password)
40 if pg_admin == false then 41 if pg_admin == nil then
41 return 42 return
42 end 43 end
43 local db = database(pg_admin) 44 local db = database(pg_admin)
44 local exists = db.query("select rolname from pg_roles where rolname=?",domain).results() ~= nil; 45 local exists = db.query("select rolname from pg_roles where rolname=?",domain).results() ~= nil;
45 --logger.info("exists "..exists) 46 --logger.info("exists "..exists)
48 end 49 end
49 db.close() 50 db.close()
50 end 51 end
51 52
52 function Util.check_postgres_password(domain,password) 53 function Util.check_postgres_password(domain,password)
53 if pg_admin == false then 54 if pg_admin == nil then
54 return 55 return
55 end 56 end
56 local db = database(pg_admin) 57 local db = database(pg_admin)
57 local exists = db.query("select rolname from pg_roles where rolname=?",domain).results() ~= nil; 58 local exists = db.query("select rolname from pg_roles where rolname=?",domain).results() ~= nil;
58 db.close() 59 db.close()