/
dbconnect.renc
32 lines (26 loc) · 964 Bytes
/
dbconnect.renc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
REBOL[Title: "DB Connect script tbv MySQL database"]
date-to-epoch: func [
"Return date in unix time format from a date in REBOL format"
rebol-date [date!] "Date in REBOL time format"
][
if rebol-date/time = null [
rebol-date: to-date rejoin [rebol-date "/00:00:00"]
]
;print [rebol-date]
rebol-date: rebol-date - now/zone
;print [rebol-date]
return to-integer (rebol-date - 1-Jan-1970 * 86400) +
(rebol-date/time/hour * 3600) +
(rebol-date/time/minute * 60) + rebol-date/time/second
]
if db-environment = null [db-environment: "test" debug: true]
do to-file unspaced ["dbconnection-" db-environment ".renc"]
dbhandle: mysql-connect dbhost dbuser dbpswd dbdbnm
if debug [print "DB handle geopend!"]
db-disconnect: does [
mysql-close dbhandle
if debug [print "DB handle closed!"]
]
db-query: func [query [text!]][
mysql-query dbhandle query
]