I'm searching the Internet for about an hour or so, but can't find a solution for my problem:
I'm trying to set up a Database connection. If I open the connection like this everything works fine:
db = pymysql.connect(host='127.0.0.1', user='python', db='test')
But if i want to set up the connection via string I get an error:
db_file = str("host='127.0.0.1', user='python', db='test'")
db = pymysql.connect(db_file)
Errormessage:
pymysql.err.OperationalError: (2003, 'Can\'t connect to MySQL server on "host=\'127.0.0.1\', user=\'python\', db=\'test\'" ([Errno -2] Name or service not known)')
I hope anybody can help me out by telling me how to set up the database connection via string(or something else predefineable)