From c728e6d2448d3f23c568e30a43ab8fdcc8785f96 Mon Sep 17 00:00:00 2001 From: Alexander_Kabui Date: Mon, 23 Jan 2023 13:40:31 +0300 Subject: extract db connection --- .../correlation/correlation_file_generator.py | 26 +++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/wqflask/wqflask/correlation/correlation_file_generator.py b/wqflask/wqflask/correlation/correlation_file_generator.py index 401b3ba6..e06c4123 100644 --- a/wqflask/wqflask/correlation/correlation_file_generator.py +++ b/wqflask/wqflask/correlation/correlation_file_generator.py @@ -2,6 +2,29 @@ from urllib.parse import urlparse import pymysql as mdb import os import csv +import lmdb +import os +import tempfile + + + +def parse_db_url(): + """function to parse SQL_URI env variable note:there\ + is a default value for SQL_URI so a tuple result is\ + always expected""" + parsed_db = urlparse(SQL_URI) + + + return ( + parsed_db.hostname, parsed_db.username, parsed_db.password, + parsed_db.path[1:], 3306) + + +# This function is deprecated. Use database_connection instead. +def database_connector(): + """function to create db connector""" + host, user, passwd, db_name, db_port = parse_db_url() + return mdb.connect(host=host,user=user,password=passwd,database=db_name) def get_probesetfreezes(conn, inbredsetid=1): @@ -107,9 +130,6 @@ def generate_csv_file(conn,db_name,txt_dir,file_name): # file name ,file expiry,type of storage - # I want to use lmdb to store the files - # file name already done #import that - # file expiry to be done lt try: -- cgit v1.2.3