-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdbConnection.py
31 lines (25 loc) · 1.04 KB
/
dbConnection.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import pymssql
from tensorflow.keras.preprocessing import image
conn = pymssql.connect(server='10.1.37.177', port='1033', user='muesd', password='Mues*dev.1', database='mues_dev')
cursor = conn.cursor()
cursor.execute("SELECT TOP 100 F.ESER_ID, F.FOTOGRAF_PATH FROM ESER_FOTOGRAF F LEFT JOIN ESER E ON F.ESER_ID = E.ID WHERE ANA_FOTOGRAF = 1 AND E.AKTIF = 1 AND E.SILINMIS = 0 order by F.ESER_ID")
records = cursor.fetchall()
print("Total rows are: ", len(records))
fs = "/mnt/muesfs/mues-images/image/ak/"
for row in records:
print("id: ", row[0], row[1])
print("\n")
try:
img = image.load_img(fs + row[1])
img = image.img_to_array(img)
print(img)
except:
print("file not found")
# get path from db
# preprocess the photo
# give the photo and get the vector from the model
# TODO: get the featureVector
# save the vector to the Milvus DB
# cursor.execute("UPDATE ESER_FOTOGRAF set DOLASIM_KOPYASI_PATH = 'X' where ANA_FOTOGRAF=1 AND ESER_ID=" + str(row[0]));
conn.commit()
conn.close()