3.8. Summary

3.8. Summary

The odbchelper.py program and its output should now make perfect sense.


def buildConnectionString(params):
    """Build a connection string from a dictionary of parameters.

    Returns string."""
    return ";".join(["%s=%s" % (k, v) for k, v in params.items()])

if __name__ == "__main__":
    myParams = {"server":"mpilgrim", \
                "database":"master", \
                "uid":"sa", \
                "pwd":"secret" \
                }
    print buildConnectionString(myParams)

Here is the output of odbchelper.py:

server=mpilgrim;uid=sa;database=master;pwd=secret

Before diving into the next chapter, make sure you're comfortable doing all of these things: