<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def dbcmd(action, *args):
 """ A dispatcher to the database server. :param action: database action to perform :param args: arguments """

    global sock
    if sock is None:
        sock = zeromq.Socket(
            'tcp://%s:%s' % (config.dbserver.host, DBSERVER_PORT),
            zeromq.zmq.REQ, 'connect').__enter__()
        # the socket will be closed when the calculation ends
    res = sock.send((action,) + args)
    if isinstance(res, parallel.Result):
        return res.get()
    return res