File: mongodb_support.py

package info (click to toggle)
python-mongoengine 0.29.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 908 kB
  • sloc: python: 7,194; makefile: 57; sh: 17
file content (24 lines) | stat: -rw-r--r-- 624 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
"""
Helper functions, constants, and types to aid with MongoDB version support
"""

from mongoengine.connection import get_connection

# Constant that can be used to compare the version retrieved with
# get_mongodb_version()
MONGODB_34 = (3, 4)
MONGODB_36 = (3, 6)
MONGODB_42 = (4, 2)
MONGODB_44 = (4, 4)
MONGODB_50 = (5, 0)
MONGODB_60 = (6, 0)
MONGODB_70 = (7, 0)


def get_mongodb_version():
    """Return the version of the default connected mongoDB (first 2 digits)

    :return: tuple(int, int)
    """
    version_list = get_connection().server_info()["versionArray"][:2]  # e.g: (3, 2)
    return tuple(version_list)