You can download this code by clicking the button below.
This code is now available for download.
This function takes a SQLAlchemy table object as an argument and returns a random column name from that table.
Technology Stack : SQLAlchemy, inspect, random
Code Type : Function
Code Difficulty : Intermediate
def generate_random_column_name(table):
from sqlalchemy import inspect
from random import choice
table_inspector = inspect(table)
column_names = table_inspector.column_names
return choice(column_names)