Add SQLite support (default database)
This commit is contained in:
parent
290c1337eb
commit
e4437dc6e3
18
main.go
18
main.go
|
|
@ -10,6 +10,7 @@ import (
|
|||
"github.com/astaxie/beego/logs"
|
||||
"github.com/astaxie/beego/orm"
|
||||
_ "github.com/go-sql-driver/mysql"
|
||||
_ "github.com/mattn/go-sqlite3"
|
||||
)
|
||||
|
||||
var (
|
||||
|
|
@ -18,10 +19,21 @@ var (
|
|||
|
||||
func init() {
|
||||
log.SetLogger("console", "")
|
||||
url := ""
|
||||
db := ""
|
||||
if database.DatabaseInstance == database.MySQL {
|
||||
// MySQL
|
||||
orm.RegisterDriver(database.MySQL, orm.DR_MySQL)
|
||||
url = database.UserDB + ":" + database.PwdDB + "@/" + database.DataBase + "?charset=utf8"
|
||||
db = "mysql"
|
||||
} else {
|
||||
// SQLite
|
||||
orm.RegisterDriver(database.SQLITE, orm.DR_Sqlite)
|
||||
url = "datahouse.db"
|
||||
db = "sqlite3"
|
||||
}
|
||||
|
||||
orm.RegisterDriver("mysql", orm.DR_MySQL)
|
||||
url := database.UserDB + ":" + database.PwdDB + "@/" + database.DataBase + "?charset=utf8"
|
||||
err := orm.RegisterDataBase(database.Alias, "mysql", url)
|
||||
err := orm.RegisterDataBase(database.Alias, db, url)
|
||||
if err != nil {
|
||||
log.Error("Failed to register database", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,9 +5,13 @@ import (
|
|||
)
|
||||
|
||||
var (
|
||||
SQLITE = "sqlite"
|
||||
MySQL = "mysql"
|
||||
Alias = "default"
|
||||
UserDB = beego.AppConfig.String("mysqluser")
|
||||
PwdDB = beego.AppConfig.String("mysqlpass")
|
||||
HostDB = beego.AppConfig.String("mysqlurls")
|
||||
DataBase = beego.AppConfig.String("mysqldb")
|
||||
|
||||
DatabaseInstance = beego.AppConfig.String("database")
|
||||
UserDB = beego.AppConfig.String("mysqluser")
|
||||
PwdDB = beego.AppConfig.String("mysqlpass")
|
||||
HostDB = beego.AppConfig.String("mysqlurls")
|
||||
DataBase = beego.AppConfig.String("mysqldb")
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
package variables
|
||||
|
||||
const (
|
||||
Version = "0.0.4"
|
||||
Version = "0.0.4.1"
|
||||
|
||||
SessionName = "Session_Data_House"
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,18 @@
|
|||
<script type="text/javascript">
|
||||
$(function () {
|
||||
chart1 = new Highcharts.StockChart({
|
||||
chart: {renderTo : 'graphe'},
|
||||
chart: {
|
||||
renderTo : 'graphe',
|
||||
load : function () {
|
||||
// set up the updating of the chart each second
|
||||
var series = this.series[0];
|
||||
setInterval(function () {
|
||||
var x = (new Date()).getTime(), // current time
|
||||
y = Math.round(Math.random() * 100);
|
||||
series.addPoint([x, y], true, true);
|
||||
}, 1000);
|
||||
}
|
||||
},
|
||||
rangeSelector: {
|
||||
buttons: [{
|
||||
count: 3,
|
||||
|
|
|
|||
Loading…
Reference in New Issue