I have a database with a Table "Neon". I am trying to get all the keywords associated with the table "Neon" related to a search string.
Example:
Neon Records:
POLICY_NUM DAYS_TO_BOUND
0170254497 PL Rating
0755698054 PL Rating
1525668307 PL Rating
1525668312 Air
1525668314 Java
1525668356 Sand
and I have a search string
"Save the day by Sand and Java"
I want to get the results like
['Sand':'1525668356','Java':'1525668314']
Trails Done are connecting to Database and Extracting Table Data
import pandas as pd
import logging
import config
from sqlalchemy import create_engine # install mysqlConnector and PyMySql
def db_connection():
"""
:return:
"""
try:
engine = create_engine('mysql+pymysql://{0}:{1}@{2}/{3}'.format(config.database_config['user'],
config.database_config['password'],
config.database_config['host'],
config.database_config['database']))
return engine
except Exception as e:
logging.info(e)
finally:
pass
def extract_table(query):
"""
:param query:
:return:
"""
engine = db_connection()
sql_select_query = query
details = pd.read_sql(sql_select_query, engine)
return details
database_query = {
'select_query_for_data': 'select * from Neon'
}
Please let me know your thoughts on this.