开发者

Python - PHP Shared MySQL server connection info?

I have some MySQL database server information that needs to be shared between a Python backend and a PHP frontend.

What is the best way to go about storing the information in a manner wherein it can be read easily by Python and PHP?

I can always brute force it with a bunch of str.replace() calls in Python and hope it works if nobody has a solution, or I can just maintain two separate files, but it would be a bunch easier if I could do this automatically.

开发者_StackOverflow社区

I assume it would be easiest to store the variables in PHP format directly and do conversions in Python, and I know there exist Python modules for serializing and unserializing PHP, but I haven't been able to get it all figured out.

Any help is appreciated!


Store the shared configuration in a plain text file, preferably in a standard format.

You might consider yaml, ini, or json.

I'm pretty sure both PHP and python can very trivially read and parse all three of those formats.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜