def create_table_if_need(obj: object, conn):
    """
        根据任意对象obj成员对象来创建表
        obj的成员对象必须赋初始值
    """
    table_name = obj.__class__.__name__
    cursor = conn.cursor()
    sql = (
        'create table if not exists %s ( id   int primary key  not null, ' %
        table_name)
    for attr in dir(obj):
        if attr.startswith('__') and attr.endswith('__'):
            continue
        if attr == 'id':
            continue
        sql += attr + '   ' + obj.__getattribute__(attr
            ).__class__.__name__ + ','
    length = len(sql)
    sql = sql[0:length - 1]
    sql += ');'
    cursor.execute(sql)
    conn.commit()
    cursor.close()
