Exemple #1
0
def storeKeyToDatabase(TID, Key):
    value = True
    try:
        mydb = connectDatabase("localhost", "encauth", "1234", "development")
        mycursor = mydb.cursor()
        query = f"INSERT INTO keyman (TID,AESkey) VALUES('{TID}',{Key})"
        executeInsertQuery(mydb, mycursor, query)
    except:
        value = False
    return value
Exemple #2
0
def getKeyFromDatabase(TID):
    value = True
    data = {}
    try:
        mydb = connectDatabase("localhost", "encauth", "1234", "development")
        mycursor = mydb.cursor()
        query = f"SELECT * FROM keyman WHERE TID = '{TID}'"
        myresult = executeSelectQuery(mycursor, query)
        if (len(myresult) == 1):
            data['TID'] = myresult[0][0]
            data['Key'] = myresult[0][1]
        else:
            data['TID'] = data['Key'] = None
            value = False
    except:
        data['TID'] = data['Key'] = None
        value = False

    return (value, data)
Exemple #3
0
def create_person_main(data):
    db = connectDatabase()       # initialization database
    requests.packages.urllib3.disable_warnings(InsecureRequestWarning)

    Key = global_var.key
    CF.Key.set(Key)

    BASE_URL = global_var.BASE_URL  # Replace with your regional Base URL
    CF.BaseUrl.set(BASE_URL)

    print("personGroupId = %s" %(global_var.personGroupId))

    
    res = CF.person.create(global_var.personGroupId, data)
    #print("res = {}".format(res)) 
    print(res)
    Id = data[-2:]

    is_exist = db.isExist(Id)
    if is_exist:
        db.update(Id,res['personId'],'personId')
        
    print("Person ID successfully added to the database")
Exemple #4
0
import cv2  # openCV
import numpy as np  # for numpy arrays
# import sqlite3
from database import connectDatabase
import os  # for creating folders

db = connectDatabase()
cap = cv2.VideoCapture(0)
cap.set(cv2.CAP_PROP_FRAME_WIDTH, 512)
cap.set(cv2.CAP_PROP_FRAME_HEIGHT, 512)

face_detection = cv2.CascadeClassifier('haarcascade_frontalface_default.xml')


# if student exist in the database
# updates otherwise inserts
def insertOrUpdate(Id, Name, roll):  # this function is for database
    isExist = db.isExist(Id)
    print('IsExist: ', isExist)
    if isExist:
        db.update(Id, Name)
        db.update(Id, roll, 'Roll')
    else:
        db.insert(Id, Name, roll)


def add_student_main(name, roll):

    Id = roll[-2:]
    insertOrUpdate(Id, name, roll)  # calling the sqlite3 database
Exemple #5
0
def getRegistrationDetailsFromDatabase(secret_number):
    mydb = connectDatabase('localhost','encauth','1234','development')
    mycursor = mydb.cursor()
    query = f"SELECT * FROM user WHERE  secret_number = {secret_number}"
    myresult = executeSelectQuery(mycursor,query)
    return myresult
Exemple #6
0
def saveRegistrationDataInDatabase(secret_number,public_key,grade):
    mydb = connectDatabase('localhost','encauth','1234','development')
    mycursor = mydb.cursor()
    query = f"INSERT INTO user (secret_number,public_key,grade) VALUES({secret_number},'{public_key}','{grade}')"
    executeInsertQuery(mydb,mycursor,query)
    return True
Exemple #7
0
		
		##GET PROPERTY PRICE (300000,15000)
		propertyPriceText = getPropertyPrice(houseproperty)
		
		##GET PROPERTY HTML
		propertyHTMLRef = getPropertyHTTPRef(houseproperty)
		
		##GET PROPERTY INFO 
		propertyInfo = getPropertyFloorArea(houseproperty)
		
		#GET PROPERTY DATE
		propertyInfo = getPropertyPublishDate(houseproperty)
		
		
		logger.debug('Connection to DB with location %s:', database_location)
		connectionDB = database.connectDatabase(database_location)
		
		logger.debug('Connection to DB OK')
		
		if(database.insertIntoHistoryPrice(connectionDB,totalNumberOfProperties,propertyPriceText,propertyTitleText,propertyInfo,totalNumberOfProperties)):
			logger.debug('insert into History Price successfully')
		else:
			logger.debug('insert into History Price with issues. Please check')
		
		
		database.commitDatabase(connectionDB)
					
		totalNumberOfProperties+=1							
	
	logger.debug('#############################################END NEW PAGE TO SCRAP#############################################')
				
        log(e)
    except IOError as e:
        log('配置文件读取失败,错误信息:')
        log(e)
    else:
        LISTEN_PORT = config['Server']['ListenPort']
        DATABASE_NAME = config['Database']['Name']
        DATABASE_ADDRESS = config['Database']['Address']
        DATABASE_PORT = config['Database']['Port']
        DATABASE_USERNAME = config['Database']['Username']
        DATABASE_PASSWORD = config['Database']['Password']
        NOTE_FILE_POSITION = config['File']['NoteFilePosition']

        # 连接数据库。如果连接失败直接退出程序
        try:
            connectDatabase(DATABASE_ADDRESS, DATABASE_PORT, DATABASE_NAME, DATABASE_USERNAME,
                            DATABASE_PASSWORD)
        except IOError as e:
            log('数据库连接失败,错误信息:')
            log(e)
        else:
            try:
                # 创建存放笔记文件用的文件夹
                os.makedirs(NOTE_FILE_POSITION, 0o777, True)
            except IOError as e:
                log('笔记存储文件夹不存在且创建失败,错误信息:')
                log(e)
            else:
                # Flask 设置
                app = Flask(__name__, static_folder = 'static/build')
                app.secret_key = os.urandom(24)