I\'m writing a Python script which uses a MySQL database, which is locally hosted. The program will be delivered as source code. As a result, the MySQL password will be visible
In this case, I create a new section in my .my.cnf, like
[files]
host=127.0.0.1
port=3307
database=files
default-character-set=utf8
password=foobar
and use it on DB initialization with
d=MySQLdb.connect(
read_default_group='files',
port=0, # read from .my.cnf
db='files',
cursorclass=cursors.DictCursor,
# amongst other stuff
)