Mahamoud BRAHIM ADOUMimport pypyodbc
import time
db = pypyodbc.connect(
'Driver={SQL Server};'
'Server=DESKTOP-F2KQL93\SQLEXPRESS;'
'Database=Kitaplar;'
'UID=sa;'
'PWD=mba;'
)
imlec = db.cursor()
with open("words.txt", "r", encoding="utf-8") as file:
words = file.read().splitlines()
while(1):
import pymongo
import time
#client = pymongo.MongoClient("mongodb://193.255.152.30:27017")
#client = pymongo.MongoClient("mongodb://10.40.44.111:27017")
client = pymongo.MongoClient()
db = client["TestDB"]
col_list = ["None"]
#col_list = ["None", "MWCANone", "Snappy", "MWCASnappy", "Zlib", "MWCAZlib", "Zstd", "MWCAZstd"]
with open("words.txt", "r", encoding="utf-8") as file:
words = file.read().splitlines()
while(1):
print("\nCOLLECTIONS:")
counter = 1
for i in col_list:
print (counter, "-", i)
counter += 1
col_no = int(input("Enter the number of the collection to search: "))
collection = db[col_list[col_no-1]]
print("... Searching for the word 'set' in '" + col_list[col_no-1] + "' ... (*)")
print("(*) First search in a collection can be slow as it requires SSD->RAM transfer.")
start = time.time()
count = collection.count_documents({"$text":{"$search": "set"}})
etime = "%.2f"%(1000*(time.time()-start))
print("Found 'set' in", count, "documents in", etime, "ms")
print("... Searching 100 words taken from 'words.txt' ...")
print("%-15s %6s %9s" % ("WORD", "COUNT", "TIME(ms)"))
total = 0
for word in words:
start = time.time()
count = collection.count_documents({"$text":{"$search": word}})
etime = "%.2f"%(1000*(time.time()-start))
print("%-15s %6s %9s" % (word, count, etime))
total += float(etime)
print("... Total Time: %.2f ms ..." % total)