You can download this code by clicking the button below.
This code is now available for download.
This function retrieves the current database version number using the Alembic library and generates a new random version number. The new version number is incremented by a random floating-point number between 0.1 and 0.9 based on the original version number.
Technology Stack : Alembic library, Python random module
Code Type : The type of code
Code Difficulty :
def generate_random_version_number():
from alembic import command
import random
engine, version = command.current_version()
new_version = version + ".0" # Increment the version number by 0.1
new_version_number = random.uniform(0.1, 0.9)
new_version = f"{version.split('.')[0]}.{version.split('.')[1]}{new_version_number:.1f}"
return new_version