<jupyter_start><jupyter_text>pymongo (Database connection)<jupyter_code>import pymongo
from config import dbuser, dbpassword
# database connection setup
conn = f"mongodb://{dbuser}:{<EMAIL>:18558/dogpedia"
client = pymongo.MongoClient(conn)
db = client.dogpedia
collection = db.breeds
collection.find_one()['breed']<jupyter_output><empty_output><jupyter_text>Flask_pymongo (DB connection in Flask environment)<jupyter_code>from flask import Flask, jsonify, render_template
from flask_pymongo import PyMongo
app = Flask(__name__)

# Use pymongo to set up mongo connection and access a database
app.config["MONGO_URI"] = f"mongodb://{dbuser}:{dbpassword}@<EMAIL>.ml<EMAIL>:18558/dogpedia"
mongo = PyMongo(app)
breeds = mongo.db.breeds.find_one()['breed']
type(breeds)
import json
from pprint import pprint
data = json.loads(open('petStoreStates.json').read())
pprint(data)
states = []
for state in data['features']:
    states.append(state['properties']['NAME'])
len(states)<jupyter_output><empty_output><jupyter_text>Insert a number of business data into geojson and store the data in MongoDB<jupyter_code>import pandas as pd
data_df = pd.read_csv('BP_2016_00A1_with_ann.csv')
data_df
values = list(data_df['Number of establishments'])
len(values)
i = 0
for state in data['features']:    
    state['properties']['BUSINESS'] = values[i]
    i += 1
pprint(data)
collection = db.pet_stores
collection.insert_one(data)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12673130193905818, 'fraction_numerical': 0.013157894736842105, 'mean_word_length': 7.601190476190476, 'pattern_counts': {'":': 0, '<': 16, '<?xml version=': 0, '>': 16, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '29855', 'license': 'MIT', 'n_tokens_mistral': 528, 'n_tokens_neox': 502, 'n_words': 109, 'path': 'db/.ipynb_checkpoints/geojson to mongoDB using PyMongo-checkpoint.ipynb', 'repo_name': 'karawenz01/dogpedia', 'size': '1466'}