Skip to content

Instantly share code, notes, and snippets.

@amitrani6
Last active August 2, 2019 09:46
Show Gist options
  • Save amitrani6/6e363af2f603d71846c7968649646645 to your computer and use it in GitHub Desktop.
Save amitrani6/6e363af2f603d71846c7968649646645 to your computer and use it in GitHub Desktop.
Creation of a database and collection
#This code creates the mongo collection once you initialize a mongo
#shell in a terminal window by simply typing the command 'mongo'
import pymongo
#The default URI is revealed once a mongo shell is initiated
#If necessary, replace the URI with the port that the database
#is located in
client = pymongo.MongoClient("mongodb://127.0.0.1:27017/")
#The name of the client is 'television_data'
db = client['television_data']
#The name of the collection is 'product_information'
product_info_collection = db['product_information']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment