package main

import (
"fmt"
"github.com/astaxie/beego/orm"
"mybee/models"
_ "mybee/routers"
"github.com/astaxie/beego" _ "github.com/lib/pq"
) func init() {
// PostgreSQL 配置
orm.RegisterDriver("postgres", orm.DRPostgres) // 注册驱动
orm.RegisterDataBase("default", "postgres", "user=odoo password=odoo dbname=mybee host=127.0.0.1 port=15432 sslmode=disable") // 自动建表
orm.RunSyncdb("default", false, true)
} func main() {
orm.Debug = true
o := orm.NewOrm()
o.Using("default")
user := new(models.User)
user.Name = "tom"
user.Age = 25 fmt.Println(o.Insert(user))
beego.Run()
}
package models

import (
"github.com/astaxie/beego/orm"
) type User struct {
Id int64
Name string
Age int
} func init() {
orm.RegisterModel(new(User))
}

  

最新文章

  1. HDU3371 最小生成树
  2. Java将文件转为字节数组
  3. this和$(this)区别
  4. yii::app(); 怎么得到module、controller、action的名字
  5. 移动设备上的媒体查询 CSS media queries for mobile device
  6. 使用git批量删除分支
  7. 04_天气查询_JAX-WS方式_服务端
  8. windows for windows:下载、安装
  9. Android TimeAnimator
  10. LOJ 534 花团(线段树+dfs栈)
  11. codesmith连接postgresql修复bug
  12. Grasshopper操作shp
  13. phper必知必会(二)
  14. react中的children使用方法
  15. STM32启动代码分析
  16. 3.Hadoop测试Yarn和MapReduce
  17. yum命令具体解释
  18. 微信支付的SDK曝出重大漏洞(XXE漏洞)
  19. shell set 命令
  20. 【整理】mysql中information_schema.tables字段说明

热门文章

  1. ORA-00904: 标识符无效——解决方案
  2. Struts1使用技巧
  3. DAY11-MYSQL补充之SQL逻辑查询语句执行顺序
  4. AOP基础-JDK动态代理
  5. mahout in Action研读(1)-给用户推荐图书
  6. Eclipse Maven 编译错误 Dynamic Web Module 3.0 requires Java 1.6 or newer 解决方案
  7. Android中pull解析XML文件的简单使用
  8. [patl2-007]家庭房产
  9. 数组中的最大值以及最小值的位置变换的问题(C++)
  10. cakephp静态资源404