0

I am storing my Database connection information in a Dictionary. Now i would like to create my sqlalchemy connection string from this dictionary d

d={"username":"max",
   "password":"admin",
   "server":"exampleserver",
   "port":"5050",
   "Database":"DB1"}

Is there a better way to convert a dictioniary to the string

mssql+pyodbc://max:admin@exampleserver:5050/DB1

than using string format

s="mssql+pyodbc://{0}:{1}@{2}:{3}/{4}".format(d['username'],d['password'],d['server'],d['port'],d['Database'])

Thanks

jan-seins
  • 1,253
  • 1
  • 18
  • 31

0 Answers0