I have created a database(name=test)
in mysql which stores the required configuration details in a table(name=config)
to connect to other database as:
+-----+-------------+----------------+---------+-------------+------------+
| host | user | password| db | charset | cursorclass | drivername |
+-------+--------------+-------+----+---------+-------------+------------+
| ***** | **** | ******* | ****** | ***** | NULL | pymysql |
+------+-----+------+-----------+---------+-------------+------------+
Now using these values how can I establish a connection to other mysql database and these are running in local machines on same network.
I tried fetching the values to put in to configuration.py file as:(This is where I could not get any idea but tried my luck which doesn't work anyway )
def getdata():
n = cursor.execute('select * from config')
c = cursor.fetchall()
lst=[]
for i in c:
lst.append([i[0],i[1],i[2],i[3],i[4],i[5]])
return str(lst[0]])
I want to fetch the data from test db and use them as values in configuration file, any help is appreciated------------ Is there a way to approach to this??
configuration.py file:
import pymysql
connection=pymysql.connect(host='',
port= ,
user='',
password='',
db='',
charset='',
cursorclass=pymysql.cursors.DictCursor)