๐ฏ
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| orm.RegisterDataBase("db1", "mysql", "root:root@/orm_db2?charset=utf8") | |
| orm.RegisterDataBase("db2", "sqlite3", "data.db") | |
| o1 := orm.NewOrm() | |
| o1.Using("db1") | |
| o2 := orm.NewOrm() | |
| o2.Using("db2") | |
| // After switching database |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func (c *UserController) GetOne() { | |
| o := orm.NewOrm() | |
| var user models.User | |
| idStr := c.Ctx.Input.Param(":id") | |
| // ๋ง์ผ ํ๋์ผ๋ก ๋์ด์จ ํค๊ฐ์ผ๋ก ์ป์ ์ ์ ์ด๋ฆ์ด ๋ค๋ฅด๊ฑฐ๋ | |
| // ๋๋ ๊ด๋ฆฌ์๋ ์ํผ์ ์ ๊ฐ ์๋๊ฒฝ์ฐ์ 401์๋ฌ๋ฅผ ๋ ๋ฆฝ๋๋ค | |
| // ํ์ฌ ์ธ์ ์ ๋ฉ๋ชจ๋ฆฌ๋ก ํ๊ธฐ๋๋ฌธ์ 60์ด ๋ค์ ๋ ๋ผ๊ฐ | |
| // mysql๋ก ์ค์ ๋ณ๊ฒฝ ํ์ | |
| username := c.GetSession("Username") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func (this *TestController) Show3() { | |
| o := orm.NewOrm() | |
| var arc []*models.Archives | |
| o.QueryTable("go_archives").Filter("Id__gt", 1).RelatedSel().All(&arc)//ไฝฟ็จRelatedSelๅฐๅ ณ่็arctypeไนๆฅๅบๆฅ๏ผไนๅฐฑๆฏleft join arctype as T1 on T1.id=go_archives.arctype_id | |
| arc3 := arc[0] | |
| fmt.Println(arc3.Arctype.Typename) | |
| }// ์ด๋ฐ์์ผ๋กํด์ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import ( | |
| "github.com/astaxie/beego" | |
| ) | |
| func (c *AdminController) Logindo() { | |
| username := c.GetString("username") | |
| c.SetSession("Adminname", username) //่ฎพ็ฝฎSession | |
| adminName := c.GetSession("Adminname") //่ฏปๅSession | |
| c.DelSession("Adminname") //ๅ ้คSession | |
| c.TplNames = "admin/login.html" | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "beegoorm/models" | |
| "fmt" | |
| "github.com/astaxie/beego" | |
| "github.com/astaxie/beego/orm" | |
| _ "beegoorm/routers" | |
| _ "github.com/go-sql-driver/mysql" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| # -*- coding: utf-8 -*- | |
| import os | |
| import unittest | |
| import mock | |
| import pytest | |
| from fots import abc_urandom, my_random |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| # -*- coding: utf-8 -*- | |
| import os | |
| from os import urandom | |
| import mock | |
| import unittest | |
| import pytest | |
| from fots import abc_urandom |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import unittest | |
| from os import urandom | |
| import mock | |
| def simple_urandom(length): | |
| return 'f' * length | |
| class TestRandom(unittest.TestCase): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| a = ['Hello', 'Sydney', 'I', 'Am'] | |
| b = [1, 2, 3, -1212.022, 5523, 232441, 1000] | |
| # way 1 ๋ฐฉ๋ฒ1 | |
| with open("foo.txt", "w") as f: | |
| map(lambda var: f.write(str(var)) if var == b[-1:][0] else f.write(str(var) + " "), b) | |
| # way 2 ๋ฐฉ๋ฒ2 | |
| with open("foo.txt", "w") as f: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # ๋ณด๋ฉด ์ด๋ฐ์์ผ๋ก ์ฌ๋ฌ์ค์ ๋ผ์ธ์ ํ ์ค๋ก ๋ง๋ค ์ ์์ต๋๋ค. | |
| # style 1 | |
| current_id = return_response.data["id"] | |
| current_banking = LOLOBanking.objects.get(id=current_id) | |
| current_banking.related_id = withdraw_account_id | |
| current_banking.withdraw_type = withdraw_type | |
| current_banking.bank_type = wa.bank_type | |
| current_banking.save |