need help setting up beego orm?

agolangf · · 536 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>cant get the orm to run. </p> <p>Iam getting the following error. &#34;must have one register DataBase alias named <code>default</code>&#34; not sure why its not working? been googling about and havent found anything of use. below is my code in my main.go</p> <pre><code>func init() { orm.RegisterDriver(&#34;sqlite3&#34;, orm.DRSqlite) err := orm.RegisterDataBase(&#34;default&#34;, &#34;sqlite3&#34;, &#34;file:sqlite/podcast.db&#34;) if err != nil { panic(err) } orm.RegisterModel(new(models.Admin)) orm.RunSyncdb(&#34;default&#34;, false, true) } func main() { o := orm.NewOrm() o.Using(&#34;default&#34;) beego.Run() } </code></pre> <p>can someone tell me if iam doing something wrong with the above code. i think running the db before running beego seems wrong to me but iam not sure. i changed this around and get the same issue. any help is appreciated.</p> <hr/>**评论:**<br/><br/>eoin_ahern: <pre><p>guess im not using the orm then. lol</p></pre>

入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889

536 次点击  
加入收藏 微博
0 回复
暂无回复
添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传