JX405기_비트/mongoDB 11

Day18-1 동적 웹페이지 크롤링

selenium , webdriver_manager 설치하기 !pip install selenium !pip install webdriver_manager 필요한 부분 import from selenium import webdriver from selenium.webdriver.chrome.service import Service from webdriver_manager.chrome import ChromeDriverManager from bs4 import BeautifulSoup import time import re 크롤링할 부분 설정하기 dining_url = "https://m.diningcode.com/list.dc" chrome_options = webdriver.ChromeOptions()..

Day17-4 정적 웹사이트 파이썬을 이용한 크롤링 & MongoDB 저장

from bs4 import BeautifulSoup import urllib.request stores=[]; // 결과를 저장할 리스트 encText = urllib.parse.quote('서울') for page in range(1, 17) : Hollys_url = 'https://www.hollys.co.kr/store/korea/korStore2.do?pageNo=%d&gugun=&store=&sido='%(page) print(Hollys_url) html = urllib.request.urlopen(Hollys_url) soupHollys = BeautifulSoup(html, 'html.parser') tag_tbody = soupHollys.find('tbody') for store i..

Day17-3 몽고 디비와 Phyton 연동

파이썬 설치후 주피터 설치 jupyter notebook --notebook-dir='E:\jupyter-notebook' pymongo 설치하기 !pip install pymongo // pymongo 설치하기 mongoDB연결하기 import pymongo //모듈 불러오기 conn=pymongo.MongoClient() // 연결 db = conn.bitDB // bitDB데이터베이스 이름 users = db.users // 컬렉션 users = users.find({}).limit(3) for user in users: print(user) read // inventory에서 조회하기 inventory = db.inventory.find({},{'_id':0}) for inv in inventor..

Day17 -1 인덱싱(단일 인덱스, 복합인덱스), 텍스트 인덱스, 공간 정보 쿼

인덱싱 Query를 더욱 효율적으로 할 수 있도록 documents에 기준(key)을 정해 정렬된 목록을 생성하는 것 인덱스가 없으면 쿼리 조건에 맞는 도큐먼트를 조회하기 위해 collection scan(컬렉션의 도큐먼트를 처음부터 끝까지 조회)을 실행 몽고디비 인덱스 DB의 검색을 빠르게 하기 위하여 데이터의 순서를 미리 정해두는 과정 고정된 스키마는 없지만 원하는 필드를 인덱스로 지정하여 검색 결과를 빠르게 함 index는 한 쿼리에 한개의 index만 유효함 → 두개의 index가 필요하다면 복합index를 사용 index는 어떤 데이터가 도큐먼트에 추가되거나 수정될 때(write 작업) 그 컬렉션에 생성되어있는 index도 새로운 도큐먼트를 포함시켜 수정됨 → index 추가시 write 작업은..

Day17-0 MongoDB Day16 요약 & SQL과 비교

Review Database 생성 user database_name으로 생성 1개 이상의 collection이 존재해야 database리스트에서 확인 Database 조회 show dbs : database 리스트 확인 db : 현재 사용중인 database 확인 Collection 생성 db.createCollection(name, [option])으로 collection 생성 name은 collection 이름이고, option은 document타입으로 구성된 해당 collection의 설정값 option 객체의 속성들 capped : Boolean타입, 이 값을 true로 설정하면 capped collection을 활성화, Capped collection이란 고정된 크기를 가진 collection으..

Day16-2 MongoDB mongosh를 이용한 CRUD

CRUD Operations Create Operations 컬렉션에 새로운 도큐먼트를 추가하는 연산 db.collection.insertOne() db.collection.insertMany() Read Operations 컬렉션에서 도큐먼트를 조회하는 연산 db.collection.find() 도큐먼트를 식별할 수 있는 쿼리 필터나 기준을 지정할 수 있음 Update Operations 컬렉션에 존재하는 도큐먼트를 수정하는 연산 db.collection.updateOne() db.collection.updateMany() db.collection.replaceOne() Delete Operations 컬렉션에서 도큐먼트를 제거하기 위한 연산 db.collection.deleteOne() db.coll..

Day16-1 MongoDB 정의, 기본 개념

NoSQL "Not Only SQL" or "Not SQL" 관계형이 아닌 DBMS 빅데이터와 실시간 웹 애플리케이션에 사용됨 Twitter, Facebook, Google 등은 매일 거대한 양의 사용자 데이터를 수집 데이터 구조에 따른 분류 Key-Value Store 시스템이 단순하여 속도가 매우 빠르고 확장도 상대적으로 용이함 기본 자료 구조는 dictionary 또는 map Oracle NoSQL, Redis, Amazon Dynamo 기본적인 CRUD(Create, Read, Update, Delete) 연산에서는 우수하지만, 고급 쿼리를 수행하는 것은 어려움. Document-Based Store Key value의 쌍으로 데이터를 저장하고 검색 Document는 JSON 형태로 저장 블로깅 ..