Exemple #1
0
def document_from_sql(name, code, host, db_user, db_password, db_name,
                      table_name):
    description = get_table_description(host, db_user, db_password, db_name,
                                        table_name)
    try:
        document = Document(name=name, code=code)
    except:
        raise Exception('Error creating new document, check name and code.')

    fields_description = dict()
    for field in description:
        fields_description[field] = ''

    document.fields_description = str(fields_description)
    document.save()
    return document