def mkConnStr(parsed_uri):
    """
    Turn a parsed uri into a connection string suitable for the db module
    """
    if parsed_uri['scheme'] == 'sqlite':
        return parsed_uri['file'] or ':memory:'
    parts = ['dbname=%s' % parsed_uri['db']]
    for attr in ['host', 'port', 'user', 'password', 'sslmode']:
        if attr in parsed_uri:
            parts.append('%s=%s' % (attr, parsed_uri[attr]))
    return ' '.join(parts)
