๐ ๊ณต๋ถํ๋ ์ง์ง์ํ์นด๋ ์ฒ์์ด์ง?
[FuncAnimation] 4. Mongo DB์ ์๊ณ์ด ๋ฐ์ดํฐ ์ ์ฅํ๊ธฐ (2) ๋ณธ๋ฌธ
[FuncAnimation] 4. Mongo DB์ ์๊ณ์ด ๋ฐ์ดํฐ ์ ์ฅํ๊ธฐ (2)
์ง์ง์ํ์นด 2022. 10. 25. 11:19221025 ์์ฑ
<๋ณธ ๋ธ๋ก๊ทธ๋ 3dpit ๋์ ๋ธ๋ก๊ทธ๋ฅผ ์ฐธ๊ณ ํด์ ๊ณต๋ถํ๋ฉฐ ์์ฑํ์์ต๋๋ค>
https://3dpit.tistory.com/398?category=819929
WEB ๋ง๋ค๊ธฐ - 0 ๋ฆฌ์กํธ ์ด๊ธฐ ์ค์
vs code ๋ค์ด๋ก๋ํ๊ธฐ code.visualstudio.com/ Visual Studio Code - Code Editing. Redefined Visual Studio Code is a code editor redefined and optimized for building and debugging modern web and cloud a..
3dpit.tistory.com
๐ฅฉ DB ๋ฃ๊ธฐ ์ฑ๊ณต
# 8. MongoDB ์ ์ฅํ๊ธฐ
data_dict = load_file()
data_dict = pd.DataFrame(data_dict)
data_dict = data_dict.to_dict("records")
# print(data_dict)
#data_dict = data_dict.to_dict("records") # ๋ฐ์ดํฐ๋ฅผ ์ฌ์ ํ์ผ๋ก
client = MongoClient("mongodb+srv://gani:hilee5868@cluster0.h7jyl5v.mongodb.net/?retryWrites=true&w=majority")
db = client.queinfo_20220929
doc = {'name':'jk','age':26}
db.cnt_item.insert_many(data_dict)
๐ฅฉ MongoDB์ ์๋ ๋ฐ์ดํฐ๋ฅผ ์นํ์ด์ง์ ์ถ๋ ฅํ๊ธฐ
1. React, node.js ๋ฑ ํจํค์ง ๊น๊ธฐ ( ๋ฐ ์ฃผ์๋ฅผ ๋์ผํ๊ฒ ๋ฐ๋ผํ๊ธฐ )
https://3dpit.tistory.com/398?category=819929
2. ์ค์น ํ์ธํ๊ธฐ
"scripts": {
"start" : "node index.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
- http://localhost:3000
3. ์ ์ ๋ชจ๋ธ & ์คํค๋ง ์์ฑ
- ๋ชจ๋ธ : ์คํค๋ง๋ฅผ ๊ฐ์ธ๋ ์ญํ
- ์คํค๋ง : ํ๋ ํ๋์ ์ ๋ณด๋ฅผ ์ง์ ํด์ฃผ๋ ๊ฒ
const mongoose = require("mongoose");
const userSchema = mongoose.Schema({
name : {
type : String,
maxlength : 50
},
email : {
type : String,
trim : true,
unique : 1
},
password : {
type : String,
minlength : 5
},
lastname : {
type : String,
maxlength : 50
},
role : {
type : Number,
default : 0
},
image : String,
token : {
type : toString,
},
tokenExp : {
type : Number
},
})
const User = mongoose.model("User", userSchema)
module.exports = {User}; // ๋ค๋ฅธ ๊ณณ์ผ๋ก ๋ณด๋ด๊ธฐ ์ํด
const User = mongoose.model("User", userSchema)
module.exports = {Product}; // ๋ค๋ฅธ ๊ณณ์ผ๋ก ๋ณด๋ด๊ธฐ ์ํด
4. Git ์ค์น
: ๋ถ์ฐ ๊ด๋ฆฌ ์ ์ด ์์คํ
- .gitignore ํ์ผ ๋ง๋ค๊ธฐ
node_modules
- Git add & commit
5. Github ์ฐ๊ฒฐ
- ์๋ก์ด Repository ๋ง๋ค๊ธฐ
- ์์ ํ๊ฒ ํต์ ํ๊ธฐ ์ํด SSH ๋ผ๋ Secure Shell ์ด์ฉ
- SSH Agent ํ๋ฉด์ ์ผ๊ธฐ
eval `ssh-agent -s`
- GitHub์ ์ฐ๊ฒฐํ๋ ๋ฐ ์ฌ์ฉ ํ๋ ค๋ ๊ธฐ์กด ๊ณต๊ฐ ๋ฐ ๊ฐ์ธ ํค ์(์: id_rsa.pub ๋ฐ id_rsa )์ด ๋์ด๋๋ฉด ssh-agent์ ํค๋ฅผ ์ถ๊ฐ
ssh-add ~/.ssh/id_ed25519
- github์ SSH ํค ์ถ๊ฐํ๊ธฐ
- .ssh ์์ ๋ณต๋ถํด์ ๋ถ์ฌ๋ฃ๊ธฐ
- git remote ํ๊ธฐ
- ๋ฐ์ push ์ด์ฉ๊ณ ๋ง ํจ