Files
2nd/10_Wiki/Dev/Topic_Python/Python_MongoDB_Create_DB.md
T
Antigravity Agent 1cfd3bbb56 docs(10_Wiki): 위키 구조 정리 — 언어 튜토리얼 카테고리 폴더 제거 + 신규 자산 동기화
Topic_CSS/Topic_HTML/Topic_JavaScript/Topic_Prompt/Topic_Comfyui 등 기존 카테고리 폴더를 정리하고,
Topic_Graphic/Dev 등 신규 산출물과 Topics 내부 세션/메모리 기록을 동기화.
2026-07-05 00:10:59 +09:00

3.4 KiB

id, title, category, status, verification_status, canonical_id, aliases, duplicate_of, source_trust_level, confidence_score, created_at, updated_at, review_reason, merge_history, tags, raw_sources, applied_in, github_commit
id title category status verification_status canonical_id aliases duplicate_of source_trust_level confidence_score created_at updated_at review_reason merge_history tags raw_sources applied_in github_commit
python-mongodb-create-db Python MongoDB Create DB Programming_Language draft conceptual
pymongo
MongoClient
파이썬 MongoDB 데이터베이스 생성
B 0.9 2026-07-04 2026-07-04
python
mongodb
w3schools
database
pymongo
https://www.w3schools.com/python/python_mongodb_create_db.asp

Python MongoDB Create DB

🎯 한 줄 통찰 (One-line insight)

Unlike MySQL's explicit CREATE DATABASE, MongoDB is lazy — myclient["mydatabase"] doesn't actually create anything on the server until a collection with at least one document is inserted into it. [S1]

🧠 핵심 개념 (Core concepts)

  • pymongo.MongoClient(url) — connects to a MongoDB server. [S1]
  • myclient["dbname"] — references (but does not yet create) a database. [S1]
  • Lazy creation — MongoDB doesn't create the database until a collection with content exists. [S1]
  • myclient.list_database_names() — lists all databases, used to check existence. [S1]

🧩 추출된 패턴 (Extracted patterns)

  • Content-triggered creation is the opposite of SQL — where CREATE DATABASE is an explicit imperative command in SQL, MongoDB treats database existence as a side effect of inserting data, not a standalone action. [S1]

📖 세부 내용 (Details)

  • Connect and reference a database: myclient = pymongo.MongoClient("mongodb://localhost:27017/"); mydb = myclient["mydatabase"]. [S1]
  • List all databases: print(myclient.list_database_names()). [S1]
  • Check specific database: dblist = myclient.list_database_names(); if "mydatabase" in dblist: print("The database exists."). [S1]

⚖️ 모순 및 업데이트 (Contradictions & updates)

  • SQL과의 근본적 차이: SQL은 CREATE DATABASE로 즉시 생성되지만, MongoDB는 컬렉션+문서가 실제로 삽입되기 전까지 데이터베이스가 생성되지 않는다. [S1]

🛠️ 적용 사례 (Applied in summary)

현재 발견된 실제 적용 사례가 없습니다 — 다음 챕터(Create Collection, Insert)를 완료해야 실제로 데이터베이스가 존재하게 된다. [S1]

💻 코드 패턴 (Code patterns)

Connect to MongoDB and reference a database (Python):

import pymongo
myclient = pymongo.MongoClient("mongodb://localhost:27017/")
mydb = myclient["mydatabase"]

검증 상태 및 신뢰도

  • 상태: draft
  • 검증 단계: conceptual
  • 출처 신뢰도: B (W3Schools — widely used educational reference, not a primary standards body)
  • 신뢰 점수: 0.90
  • 중복 검사 결과: 신규 생성 (New discovery)

🔗 지식 그래프 (Knowledge Graph)

📚 출처 (Sources)

📝 변경 이력 (Change history)

  • 2026-07-04: Initial draft synthesized from the W3Schools "Python MongoDB Create Database" page (Astra wiki-curation, P-Reinforce v3.1 format).