Commit 283ecea4 authored by Juan José Miranda's avatar Juan José Miranda

Actualizamos los scripts a sus ultimas versiones. Maquina de Martín.

parent c94abc51
No preview for this file type
File added
File added
import random
import json
import pymongo
from datetime import datetime
import urllib.parse
username = urllib.parse.quote_plus('root')
password = urllib.parse.quote_plus('password123')
conn = pymongo.MongoClient('mongodb://%s:%s@127.0.0.1:27017' % (username, password))
db = conn['tweeter']
tweets = db.tweets
json_file_path = "../tweets_3.json"
with open(json_file_path, 'r') as data_file:
json_data = data_file.read()
arr = json.loads(json_data)
start = datetime.now()
for i in range(0,333333):
tweet = arr[i]
key = random.randint(1, 4)
tweet["key"] = f"{key:06}"
result = tweets.insert_one(tweet)
finish = datetime.now()
execution_time = (finish - start)
total_seconds = execution_time.total_seconds()
print("End Test. Time: " + str(total_seconds))
import random
import json
import pymongo
from datetime import datetime
import urllib.parse
username = urllib.parse.quote_plus('root')
password = urllib.parse.quote_plus('password123')
conn = pymongo.MongoClient('mongodb://%s:%s@127.0.0.1:27017' % (username, password))
db = conn['tweeter']
tweets = db.tweets
json_file_path = "../tweets_3.json"
with open(json_file_path, 'r') as data_file:
json_data = data_file.read()
arr = json.loads(json_data)
start = datetime.now()
for i in range(0,333333):
tweet = arr[i]
if i < 111111:
key = 1
else if i < 222222:
key = 2
else:
key = 3
tweet["key"] = f"{key:06}"
result = tweets.insert_one(tweet)
finish = datetime.now()
execution_time = (finish - start)
total_seconds = execution_time.total_seconds()
print("End Test. Time: " + str(total_seconds))
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment