【Django】如何转化已有的数据表到Django模型--20230823

这篇具有很好参考价值的文章主要介绍了【Django】如何转化已有的数据表到Django模型--20230823。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

初步生成model.py

$ python manage.py inspectdb
$ python manage.py inspectdb > models.py

python manage.py inspectdb
# This is an auto-generated Django model module.
# You'll have to do the following manually to clean this up:
#   * Rearrange models' order
#   * Make sure each model has one field with primary_key=True
#   * Make sure each ForeignKey and OneToOneField has `on_delete` set to the desired behavior
#   * Remove `managed = False` lines if you wish to allow Django to create, modify, and delete the table
# Feel free to rename the models, but don't rename db_table values or field names.
from django.db import models


class AuthGroup(models.Model):
    name = models.CharField(unique=True, max_length=150)

    class Meta:
        managed = False
        db_table = 'auth_group'


class AuthGroupPermissions(models.Model):
    id = models.BigAutoField(primary_key=True)
    group = models.ForeignKey(AuthGroup, models.DO_NOTHING)
    permission = models.ForeignKey('AuthPermission', models.DO_NOTHING)

    class Meta:
        managed = False
        db_table = 'auth_group_permissions'
        unique_together = (('group', 'permission'),)


class AuthPermission(models.Model):
    name = models.CharField(max_length=255)
    content_type = models.ForeignKey('DjangoContentType', models.DO_NOTHING)
    codename = models.CharField(max_length=100)

    class Meta:
        managed = False
        db_table = 'auth_permission'
        unique_together = (('content_type', 'codename'),)


class AuthUser(models.Model):
    password = models.CharField(max_length=128)
    last_login = models.DateTimeField(blank=True, null=True)
    is_superuser = models.IntegerField()
    username = models.CharField(unique=True, max_length=150)
    first_name = models.CharField(max_length=150)
    last_name = models.CharField(max_length=150)
    email = models.CharField(max_length=254)
    is_staff = models.IntegerField()
    is_active = models.IntegerField()
    date_joined = models.DateTimeField()

    class Meta:
        managed = False
        db_table = 'auth_user'


class AuthUserGroups(models.Model):
    id = models.BigAutoField(primary_key=True)
    user = models.ForeignKey(AuthUser, models.DO_NOTHING)
    group = models.ForeignKey(AuthGroup, models.DO_NOTHING)

    class Meta:
        managed = False
        db_table = 'auth_user_groups'
        unique_together = (('user', 'group'),)


class AuthUserUserPermissions(models.Model):
    id = models.BigAutoField(primary_key=True)
    user = models.ForeignKey(AuthUser, models.DO_NOTHING)
    permission = models.ForeignKey(AuthPermission, models.DO_NOTHING)

    class Meta:
        managed = False
        db_table = 'auth_user_user_permissions'
        unique_together = (('user', 'permission'),)


class Config(models.Model):
    id = models.BigAutoField(primary_key=True)
    config1 = models.CharField(max_length=135, blank=True, null=True)
    config2 = models.CharField(max_length=135, blank=True, null=True)
    config3 = models.CharField(max_length=135, blank=True, null=True)
    config4 = models.CharField(max_length=135, blank=True, null=True)
    config5 = models.CharField(max_length=135, blank=True, null=True)
    config6 = models.CharField(max_length=135, blank=True, null=True)
    config7 = models.CharField(max_length=135, blank=True, null=True)
    config8 = models.CharField(max_length=135, blank=True, null=True)
    config9 = models.CharField(max_length=135, blank=True, null=True)
    config10 = models.CharField(max_length=135, blank=True, null=True)
    config11 = models.CharField(max_length=135, blank=True, null=True)
    config12 = models.CharField(max_length=135, blank=True, null=True)
    config13 = models.CharField(max_length=135, blank=True, null=True)
    config14 = models.CharField(max_length=135, blank=True, null=True)
    config15 = models.CharField(max_length=135, blank=True, null=True)
    config16 = models.CharField(max_length=135, blank=True, null=True)
    config17 = models.CharField(max_length=135, blank=True, null=True)
    config18 = models.CharField(max_length=135, blank=True, null=True)
    config19 = models.CharField(max_length=135, blank=True, null=True)
    config20 = models.CharField(max_length=135, blank=True, null=True)
    config21 = models.CharField(max_length=135, blank=True, null=True)
    config22 = models.CharField(max_length=135, blank=True, null=True)
    config23 = models.CharField(max_length=135, blank=True, null=True)
    config24 = models.CharField(max_length=135, blank=True, null=True)
    config25 = models.CharField(max_length=135, blank=True, null=True)
    config26 = models.CharField(max_length=135, blank=True, null=True)
    config27 = models.CharField(max_length=135, blank=True, null=True)
    config28 = models.CharField(max_length=135, blank=True, null=True)
    config29 = models.CharField(max_length=135, blank=True, null=True)
    config30 = models.CharField(max_length=135, blank=True, null=True)
    config31 = models.CharField(max_length=135, blank=True, null=True)
    config32 = models.CharField(max_length=135, blank=True, null=True)
    config33 = models.CharField(max_length=135, blank=True, null=True)
    config34 = models.CharField(max_length=135, blank=True, null=True)
    config35 = models.CharField(max_length=135, blank=True, null=True)
    config36 = models.CharField(max_length=135, blank=True, null=True)
    config37 = models.CharField(max_length=135, blank=True, null=True)
    config38 = models.CharField(max_length=135, blank=True, null=True)
    config39 = models.CharField(max_length=135, blank=True, null=True)
    config40 = models.CharField(max_length=135, blank=True, null=True)
    config41 = models.CharField(max_length=135, blank=True, null=True)
    config42 = models.CharField(max_length=135, blank=True, null=True)
    config43 = models.CharField(max_length=135, blank=True, null=True)
    config44 = models.CharField(max_length=135, blank=True, null=True)
    config45 = models.CharField(max_length=135, blank=True, null=True)
    config46 = models.CharField(max_length=135, blank=True, null=True)
    config47 = models.CharField(max_length=135, blank=True, null=True)
    config48 = models.CharField(max_length=135, blank=True, null=True)
    config49 = models.CharField(max_length=135, blank=True, null=True)
    config50 = models.CharField(max_length=135, blank=True, null=True)

    class Meta:
        managed = False
        db_table = 'config'


class CsodTrainingAndTestRecord2(models.Model):
    id = models.BigAutoField(primary_key=True)
    user = models.CharField(db_column='USER', max_length=135, blank=True, null=True)  # Field name made lowercase.
    user_id = models.CharField(db_column='USER_ID', max_length=135, blank=True, null=True)  # Field name made lowercase.
    training_title = models.CharField(db_column='TRAINING_TITLE', max_length=135, blank=True, null=True)  # Field name made lowercase.
    training_version = models.CharField(db_column='TRAINING_VERSION', max_length=135, blank=True, null=True)  # Field name made lowercase.
    training_type = models.CharField(db_column='TRAINING_TYPE', max_length=135, blank=True, null=True)  # Field name made lowercase.
    training_vendor = models.CharField(db_column='TRAINING_VENDOR', max_length=135, blank=True, null=True)  # Field name made lowercase.
    training_status = models.CharField(db_column='TRAINING_STATUS', max_length=135, blank=True, null=True)  # Field name made lowercase.
    training_hours = models.CharField(db_column='TRAINING_HOURS', max_length=135, blank=True, null=True)  # Field name made lowercase.
    credits = models.CharField(db_column='CREDITS', max_length=135, blank=True, null=True)  # Field name made lowercase.
    training_record_date = models.DateTimeField(db_column='TRAINING_RECORD_DATE', blank=True, null=True)  # Field name made lowercase.
    accommodation_expense = models.CharField(db_column='Accommodation_Expense', max_length=135, blank=True, null=True)  # Field name made lowercase.
    apply_reason = models.CharField(db_column='Apply_Reason', max_length=135, blank=True, null=True)  # Field name made lowercase.
    compulsory_elective = models.CharField(db_column='Compulsory_Elective', max_length=135, blank=True, null=True)  # Field name made lowercase.
    course_owner = models.CharField(db_column='Course_Owner', max_length=135, blank=True, null=True)  # Field name made lowercase.
    currency = models.CharField(db_column='Currency', max_length=135, blank=True, null=True)  # Field name made lowercase.
    facility_expense = models.CharField(db_column='Facility_Expense', max_length=135, blank=True, null=True)  # Field name made lowercase.
    instructor_expense = models.CharField(db_column='Instructor_Expense', max_length=135, blank=True, null=True)  # Field name made lowercase.
    instructor_full_name = models.CharField(db_column='Instructor_Full_Name', max_length=135, blank=True, null=True)  # Field name made lowercase.
    instructor_id = models.CharField(db_column='Instructor_ID', max_length=135, blank=True, null=True)  # Field name made lowercase.
    instructor_type = models.CharField(db_column='Instructor_Type', max_length=135, blank=True, null=True)  # Field name made lowercase.
    material_expense = models.CharField(db_column='Material_Expense', max_length=135, blank=True, null=True)  # Field name made lowercase.
    meal_expense = models.CharField(db_column='Meal_Expense', max_length=135, blank=True, null=True)  # Field name made lowercase.
    note = models.CharField(db_column='Note', max_length=135, blank=True, null=True)  # Field name made lowercase.
    other_expense = models.CharField(db_column='Other_Expense', max_length=135, blank=True, null=True)  # Field name made lowercase.
    training_type_2 = models.CharField(db_column='Training_Type_2', max_length=135, blank=True, null=True)  # Field name made lowercase.
    transportation_expense = models.CharField(db_column='Transportation_Expense', max_length=135, blank=True, null=True)  # Field name made lowercase.
    unfinished_training_fee = models.CharField(db_column='Unfinished_Training_Fee', max_length=135, blank=True, null=True)  # Field name made lowercase.

    class Meta:
        managed = False
        db_table = 'csod_training_and_test_record2'


class DjangoAdminLog(models.Model):
    action_time = models.DateTimeField()
    object_id = models.TextField(blank=True, null=True)
    object_repr = models.CharField(max_length=200)
    action_flag = models.PositiveSmallIntegerField()
    change_message = models.TextField()
    content_type = models.ForeignKey('DjangoContentType', models.DO_NOTHING, blank=True, null=True)
    user = models.ForeignKey(AuthUser, models.DO_NOTHING)

    class Meta:
        managed = False
        db_table = 'django_admin_log'


class DjangoContentType(models.Model):
    app_label = models.CharField(max_length=100)
    model = models.CharField(max_length=100)

    class Meta:
        managed = False
        db_table = 'django_content_type'
        unique_together = (('app_label', 'model'),)


class DjangoMigrations(models.Model):
    id = models.BigAutoField(primary_key=True)
    app = models.CharField(max_length=255)
    name = models.CharField(max_length=255)
    applied = models.DateTimeField()

    class Meta:
        managed = False
        db_table = 'django_migrations'


class DjangoSession(models.Model):
    session_key = models.CharField(primary_key=True, max_length=40)
    session_data = models.TextField()
    expire_date = models.DateTimeField()

    class Meta:
        managed = False
        db_table = 'django_session'


class EnglishPasslist(models.Model):
    id = models.BigAutoField(primary_key=True)
    function_name = models.CharField(db_column='FUNCTION_NAME', max_length=135, blank=True, null=True)  # Field name made lowercase.
    department = models.CharField(db_column='DEPARTMENT', max_length=135, blank=True, null=True)  # Field name made lowercase.
    engfunc = models.CharField(db_column='ENGFUNC', max_length=135, blank=True, null=True)  # Field name made lowercase.
    employee_id = models.CharField(db_column='EMPLOYEE_ID', max_length=135, blank=True, null=True)  # Field name made lowercase.
    chinese_name = models.CharField(db_column='CHINESE_NAME', max_length=135, blank=True, null=True)  # Field name made lowercase.
    entry_date = models.DateTimeField(db_column='ENTRY_DATE', blank=True, null=True)  # Field name made lowercase.
    group_grade = models.CharField(db_column='GROUP_GRADE', max_length=135, blank=True, null=True)  # Field name made lowercase.
    highestscores = models.CharField(db_column='HIGHESTSCORES', max_length=135, blank=True, null=True)  # Field name made lowercase.
    highestscores_test_date = models.CharField(db_column='HIGHESTSCORES_TEST_DATE', max_length=135, blank=True, null=True)  # Field name made lowercase.
    passcurrent = models.CharField(db_column='PASSCURRENT', max_length=135, blank=True, null=True)  # Field name made lowercase.
    highestscores_2year = models.CharField(db_column='HIGHESTSCORES_2YEAR', max_length=135, blank=True, null=True)  # Field name made lowercase.
    highestscores_2year_test_date = models.CharField(db_column='HIGHESTSCORES_2YEAR_TEST_DATE', max_length=135, blank=True, null=True)  # Field name made lowercase.
    highestscores_2year_invalid_date = models.CharField(db_column='HIGHESTSCORES_2YEAR_INVALID_DATE', max_length=135, blank=True, null=True)  # Field name made lowercase.
    passcurrent_2year = models.CharField(db_column='PASSCURRENT_2YEAR', max_length=135, blank=True, null=True)  # Field name made lowercase.
    pass_high_grade_2year = models.CharField(db_column='PASS_HIGH_GRADE_2YEAR', max_length=135, blank=True, null=True)  # Field name made lowercase.
    trans_date = models.CharField(db_column='TRANS_DATE', max_length=135, blank=True, null=True)  # Field name made lowercase.
    remark = models.CharField(db_column='REMARK', max_length=135, blank=True, null=True)  # Field name made lowercase.
    buffer1 = models.CharField(max_length=135, blank=True, null=True)
    buffer2 = models.CharField(max_length=135, blank=True, null=True)
    buffer3 = models.CharField(max_length=135, blank=True, null=True)
    buffer4 = models.CharField(max_length=135, blank=True, null=True)
    buffer5 = models.CharField(max_length=135, blank=True, null=True)
    buffer6 = models.CharField(max_length=135, blank=True, null=True)
    buffer7 = models.CharField(max_length=135, blank=True, null=True)
    buffer8 = models.CharField(max_length=135, blank=True, null=True)
    buffer9 = models.CharField(max_length=135, blank=True, null=True)
    buffer10 = models.CharField(max_length=135, blank=True, null=True)
    record_date = models.DateTimeField(blank=True, null=True)

    class Meta:
        managed = False
        db_table = 'english_passlist'


class ManagementPasslist(models.Model):
    id = models.BigAutoField(primary_key=True)
    location = models.CharField(db_column='LOCATION', max_length=135, blank=True, null=True)  # Field name made lowercase.
    function_code = models.CharField(db_column='FUNCTION_CODE', max_length=135, blank=True, null=True)  # Field name made lowercase.
    function_name = models.CharField(db_column='FUNCTION_NAME', max_length=135, blank=True, null=True)  # Field name made lowercase.
    deptid = models.CharField(db_column='DEPTID', max_length=135, blank=True, null=True)  # Field name made lowercase.
    grade_range = models.CharField(db_column='GRADE_RANGE', max_length=135, blank=True, null=True)  # Field name made lowercase.
    emplid = models.CharField(db_column='EMPLID', max_length=135, blank=True, null=True)  # Field name made lowercase.
    name = models.CharField(db_column='NAME', max_length=135, blank=True, null=True)  # Field name made lowercase.
    current_range_course_total = models.CharField(db_column='CURRENT_RANGE_COURSE_TOTAL', max_length=135, blank=True, null=True)  # Field name made lowercase.
    current_range_1st_assessment_total = models.CharField(db_column='CURRENT_RANGE_1ST_ASSESSMENT_TOTAL', max_length=135, blank=True, null=True)  # Field name made lowercase.
    current_range_present_total = models.CharField(db_column='CURRENT_RANGE_PRESENT_TOTAL', max_length=135, blank=True, null=True)  # Field name made lowercase.
    current_range_2nd_assessment_total = models.CharField(db_column='CURRENT_RANGE_2ND_ASSESSMENT_TOTAL', max_length=135, blank=True, null=True)  # Field name made lowercase.
    p1_rate = models.CharField(db_column='P1_RATE', max_length=135, blank=True, null=True)  # Field name made lowercase.
    p2_rate = models.CharField(db_column='P2_RATE', max_length=135, blank=True, null=True)  # Field name made lowercase.
    p3_rate = models.CharField(db_column='P3_RATE', max_length=135, blank=True, null=True)  # Field name made lowercase.
    current_range_rate = models.CharField(db_column='CURRENT_RANGE_RATE', max_length=135, blank=True, null=True)  # Field name made lowercase.
    record_date = models.DateTimeField(blank=True, null=True)
    buffer1 = models.CharField(max_length=135, blank=True, null=True)
    buffer2 = models.CharField(max_length=135, blank=True, null=True)
    buffer3 = models.CharField(max_length=135, blank=True, null=True)
    buffer4 = models.CharField(max_length=135, blank=True, null=True)
    buffer5 = models.CharField(max_length=135, blank=True, null=True)
    buffer6 = models.CharField(max_length=135, blank=True, null=True)
    buffer7 = models.CharField(max_length=135, blank=True, null=True)
    buffer8 = models.CharField(max_length=135, blank=True, null=True)
    buffer9 = models.CharField(max_length=135, blank=True, null=True)
    buffer10 = models.CharField(max_length=135, blank=True, null=True)

    class Meta:
        managed = False
        db_table = 'management_passlist'


class PeopleData(models.Model):
    pkid = models.IntegerField(blank=True, null=True)
    batchid = models.TextField(blank=True, null=True)
    bu = models.TextField(blank=True, null=True)
    bg = models.TextField(blank=True, null=True)
    site = models.TextField(blank=True, null=True)
    plant = models.TextField(blank=True, null=True)
    emplid = models.TextField(blank=True, null=True)
    name = models.TextField(blank=True, null=True)
    name_a = models.TextField(blank=True, null=True)
    hire_dt = models.DateTimeField(blank=True, null=True)
    sal_location_a = models.TextField(blank=True, null=True)
    company = models.TextField(blank=True, null=True)
    deptid = models.TextField(blank=True, null=True)
    location = models.TextField(blank=True, null=True)
    jobtitle_descr = models.TextField(blank=True, null=True)
    emailid = models.TextField(blank=True, null=True)
    email_address_a = models.TextField(blank=True, null=True)
    phone_a = models.TextField(blank=True, null=True)
    officer_level_a = models.TextField(blank=True, null=True)
    supervisor_id = models.TextField(blank=True, null=True)
    tree_level_num = models.TextField(blank=True, null=True)
    termination_dt = models.DateTimeField(blank=True, null=True)
    labor_type = models.TextField(blank=True, null=True)
    job_family = models.TextField(blank=True, null=True)
    grade = models.TextField(blank=True, null=True)
    job_entry_dt = models.DateTimeField(blank=True, null=True)
    grade_entry_dt = models.DateTimeField(blank=True, null=True)
    job_title_a = models.TextField(blank=True, null=True)
    last_updt_dt = models.DateTimeField(blank=True, null=True)
    jobcode = models.TextField(blank=True, null=True)
    action_reason = models.TextField(blank=True, null=True)
    sex = models.TextField(blank=True, null=True)
    birthdate = models.DateTimeField(blank=True, null=True)
    batch_id = models.TextField(blank=True, null=True)
    version_id = models.IntegerField(blank=True, null=True)

    class Meta:
        managed = False
        db_table = 'people_data'


class ProfessionPasslist(models.Model):
    id = models.BigAutoField(primary_key=True)
    location = models.CharField(db_column='LOCATION', max_length=135, blank=True, null=True)  # Field name made lowercase.
    function_code = models.CharField(db_column='FUNCTION_CODE', max_length=135, blank=True, null=True)  # Field name made lowercase.
    function_name = models.CharField(db_column='FUNCTION_NAME', max_length=135, blank=True, null=True)  # Field name made lowercase.
    department = models.CharField(db_column='DEPARTMENT', max_length=135, blank=True, null=True)  # Field name made lowercase.
    employee_id = models.CharField(db_column='EMPLOYEE_ID', max_length=135, blank=True, null=True)  # Field name made lowercase.
    chinese_name = models.CharField(db_column='CHINESE_NAME', max_length=135, blank=True, null=True)  # Field name made lowercase.
    entry_date = models.DateTimeField(db_column='ENTRY_DATE', blank=True, null=True)  # Field name made lowercase.
    group_grade = models.CharField(db_column='GROUP_GRADE', max_length=135, blank=True, null=True)  # Field name made lowercase.
    effected_date = models.CharField(db_column='EFFECTED_DATE', max_length=135, blank=True, null=True)  # Field name made lowercase.
    pass_all = models.CharField(db_column='PASS_ALL', max_length=135, blank=True, null=True)  # Field name made lowercase.
    all_small_test_current = models.CharField(db_column='ALL_SMALL_TEST_CURRENT', max_length=135, blank=True, null=True)  # Field name made lowercase.
    pass_small_test_current = models.CharField(db_column='PASS_SMALL_TEST_CURRENT', max_length=135, blank=True, null=True)  # Field name made lowercase.
    all_middle_test_current = models.CharField(db_column='ALL_MIDDLE_TEST_CURRENT', max_length=135, blank=True, null=True)  # Field name made lowercase.
    pass_middle_test_current = models.CharField(db_column='PASS_MIDDLE_TEST_CURRENT', max_length=135, blank=True, null=True)  # Field name made lowercase.
    all_final_test_current = models.CharField(db_column='ALL_FINAL_TEST_CURRENT', max_length=135, blank=True, null=True)  # Field name made lowercase.
    pass_final_test_current = models.CharField(db_column='PASS_FINAL_TEST_CURRENT', max_length=135, blank=True, null=True)  # Field name made lowercase.
    all_others_test_current = models.CharField(db_column='ALL_OTHERS_TEST_CURRENT', max_length=135, blank=True, null=True)  # Field name made lowercase.
    pass_others_test_current = models.CharField(db_column='PASS_OTHERS_TEST_CURRENT', max_length=135, blank=True, null=True)  # Field name made lowercase.
    pass_testrate_current = models.CharField(db_column='PASS_TESTRATE_CURRENT', max_length=135, blank=True, null=True)  # Field name made lowercase.
    all_training_next = models.CharField(db_column='ALL_TRAINING_NEXT', max_length=135, blank=True, null=True)  # Field name made lowercase.
    pass_traning_next = models.CharField(db_column='PASS_TRANING_NEXT', max_length=135, blank=True, null=True)  # Field name made lowercase.
    pass_trainingrate_next = models.CharField(db_column='PASS_TRAININGRATE_NEXT', max_length=135, blank=True, null=True)  # Field name made lowercase.
    all_small_test_next = models.CharField(db_column='ALL_SMALL_TEST_NEXT', max_length=135, blank=True, null=True)  # Field name made lowercase.
    pass_small_test_next = models.CharField(db_column='PASS_SMALL_TEST_NEXT', max_length=135, blank=True, null=True)  # Field name made lowercase.
    all_middle_test_next = models.CharField(db_column='ALL_MIDDLE_TEST_NEXT', max_length=135, blank=True, null=True)  # Field name made lowercase.
    pass_middle_test_next = models.CharField(db_column='PASS_MIDDLE_TEST_NEXT', max_length=135, blank=True, null=True)  # Field name made lowercase.
    all_final_test_next = models.CharField(db_column='ALL_FINAL_TEST_NEXT', max_length=135, blank=True, null=True)  # Field name made lowercase.
    pass_final_test_next = models.CharField(db_column='PASS_FINAL_TEST_NEXT', max_length=135, blank=True, null=True)  # Field name made lowercase.
    all_others_test_next = models.CharField(db_column='ALL_OTHERS_TEST_NEXT', max_length=135, blank=True, null=True)  # Field name made lowercase.
    pass_others_test_next = models.CharField(db_column='PASS_OTHERS_TEST_NEXT', max_length=135, blank=True, null=True)  # Field name made lowercase.
    pass_testrate_next = models.CharField(db_column='PASS_TESTRATE_NEXT', max_length=135, blank=True, null=True)  # Field name made lowercase.
    trans_date = models.CharField(db_column='TRANS_DATE', max_length=135, blank=True, null=True)  # Field name made lowercase.
    remark = models.CharField(db_column='REMARK', max_length=135, blank=True, null=True)  # Field name made lowercase.
    pass_trans_cur = models.CharField(db_column='PASS_TRANS_CUR', max_length=135, blank=True, null=True)  # Field name made lowercase.
    pass_trans_nex = models.CharField(db_column='PASS_TRANS_NEX', max_length=135, blank=True, null=True)  # Field name made lowercase.
    buffer1 = models.CharField(max_length=135, blank=True, null=True)
    buffer10 = models.CharField(max_length=135, blank=True, null=True)
    buffer2 = models.CharField(max_length=135, blank=True, null=True)
    buffer3 = models.CharField(max_length=135, blank=True, null=True)
    buffer4 = models.CharField(max_length=135, blank=True, null=True)
    buffer5 = models.CharField(max_length=135, blank=True, null=True)
    buffer6 = models.CharField(max_length=135, blank=True, null=True)
    buffer7 = models.CharField(max_length=135, blank=True, null=True)
    buffer8 = models.CharField(max_length=135, blank=True, null=True)
    buffer9 = models.CharField(max_length=135, blank=True, null=True)
    record_date = models.DateTimeField(blank=True, null=True)

    class Meta:
        managed = False
        db_table = 'profession_passlist'


class TrainingImportCsodTrainingAndTestRecordForModel(models.Model):
    id = models.BigAutoField(primary_key=True)
    file = models.CharField(max_length=100)
    name = models.CharField(max_length=50)

    class Meta:
        managed = False
        db_table = 'training_import_csod_training_and_test_record_for_model'


class TrainingImportEnglishPasslistForModel(models.Model):
    id = models.BigAutoField(primary_key=True)
    file = models.CharField(max_length=100)
    name = models.CharField(max_length=50)

    class Meta:
        managed = False
        db_table = 'training_import_english_passlist_for_model'


class TrainingImportManagementPasslistForModel(models.Model):
    id = models.BigAutoField(primary_key=True)
    file = models.CharField(max_length=100)
    name = models.CharField(max_length=50)

    class Meta:
        managed = False
        db_table = 'training_import_management_passlist_for_model'


class TrainingImportProfessionPasslistForModel(models.Model):
    id = models.BigAutoField(primary_key=True)
    file = models.CharField(max_length=100)
    name = models.CharField(max_length=50)

    class Meta:
        managed = False
        db_table = 'training_import_profession_passlist_for_model'


class TrainingImportTrsTrainerMaintainForModel(models.Model):
    id = models.BigAutoField(primary_key=True)
    file = models.CharField(max_length=100)
    name = models.CharField(max_length=50)

    class Meta:
        managed = False
        db_table = 'training_import_trs_trainer_maintain_for_model'


class TrainingImportTrsTrainingAndTestRecordForModel(models.Model):
    id = models.BigAutoField(primary_key=True)
    file = models.CharField(max_length=100)
    name = models.CharField(max_length=50)

    class Meta:
        managed = False
        db_table = 'training_import_trs_training_and_test_record_for_model'


class TrainingImportZzRecordForModel(models.Model):
    id = models.BigAutoField(primary_key=True)
    file = models.CharField(max_length=100)
    name = models.CharField(max_length=50)

    class Meta:
        managed = False
        db_table = 'training_import_zz_record_for_model'


class TrsTrainerMaintain(models.Model):
    id = models.BigAutoField(primary_key=True)
    trainer_id = models.CharField(db_column='TRAINER_ID', max_length=135, blank=True, null=True)  # Field name made lowercase.
    trainer_name = models.CharField(db_column='TRAINER_NAME', max_length=135, blank=True, null=True)  # Field name made lowercase.
    deptment_id = models.CharField(db_column='DEPTMENT_ID', max_length=135, blank=True, null=True)  # Field name made lowercase.
    plant = models.CharField(db_column='PLANT', max_length=135, blank=True, null=True)  # Field name made lowercase.
    grade_code = models.CharField(db_column='GRADE_CODE', max_length=135, blank=True, null=True)  # Field name made lowercase.
    score = models.CharField(db_column='SCORE', max_length=135, blank=True, null=True)  # Field name made lowercase.
    honor = models.CharField(db_column='HONOR', max_length=135, blank=True, null=True)  # Field name made lowercase.
    effective_date = models.CharField(db_column='EFFECTIVE_DATE', max_length=135, blank=True, null=True)  # Field name made lowercase.
    iscurrent_grade = models.CharField(db_column='ISCURRENT_GRADE', max_length=135, blank=True, null=True)  # Field name made lowercase.
    update_user = models.CharField(db_column='UPDATE_USER', max_length=135, blank=True, null=True)  # Field name made lowercase.
    update_date = models.CharField(db_column='UPDATE_DATE', max_length=135, blank=True, null=True)  # Field name made lowercase.
    employeeid = models.CharField(db_column='EMPLOYEEID', max_length=135, blank=True, null=True)  # Field name made lowercase.
    location = models.CharField(db_column='LOCATION', max_length=135, blank=True, null=True)  # Field name made lowercase.

    class Meta:
        managed = False
        db_table = 'trs_trainer_maintain'


class TrsTrainingAndTestRecord(models.Model):
    id = models.BigAutoField(primary_key=True)
    location = models.CharField(db_column='Location', max_length=135, blank=True, null=True)  # Field name made lowercase.
    function_code = models.CharField(db_column='Function_Code', max_length=135, blank=True, null=True)  # Field name made lowercase.
    function_name = models.CharField(db_column='Function_Name', max_length=135, blank=True, null=True)  # Field name made lowercase.
    plant = models.CharField(db_column='Plant', max_length=135, blank=True, null=True)  # Field name made lowercase.
    dept = models.CharField(db_column='Dept', max_length=135, blank=True, null=True)  # Field name made lowercase.
    employee_no = models.CharField(db_column='Employee_NO', max_length=135, blank=True, null=True)  # Field name made lowercase.
    name = models.CharField(db_column='Name', max_length=135, blank=True, null=True)  # Field name made lowercase.
    grade_range = models.CharField(db_column='Grade_Range', max_length=135, blank=True, null=True)  # Field name made lowercase.
    training_type = models.CharField(db_column='Training_Type', max_length=135, blank=True, null=True)  # Field name made lowercase.
    priority = models.CharField(db_column='Priority', max_length=135, blank=True, null=True)  # Field name made lowercase.
    type = models.CharField(db_column='Type', max_length=135, blank=True, null=True)  # Field name made lowercase.
    course = models.CharField(db_column='Course', max_length=135, blank=True, null=True)  # Field name made lowercase.
    schedule_code = models.CharField(db_column='Schedule_Code', max_length=135, blank=True, null=True)  # Field name made lowercase.
    schedule_name = models.CharField(db_column='Schedule_Name', max_length=135, blank=True, null=True)  # Field name made lowercase.
    course_or_test = models.CharField(db_column='Course_or_Test', max_length=135, blank=True, null=True)  # Field name made lowercase.
    delivery_way_or_test_way = models.CharField(db_column='Delivery_Way_or_Test_Way', max_length=135, blank=True, null=True)  # Field name made lowercase.
    start_date = models.DateTimeField(db_column='Start_Date', blank=True, null=True)  # Field name made lowercase.
    end_date = models.DateTimeField(db_column='End_Date', blank=True, null=True)  # Field name made lowercase.
    present_status = models.CharField(db_column='Present_Status', max_length=135, blank=True, null=True)  # Field name made lowercase.
    pass_score = models.IntegerField(db_column='Pass_Score', blank=True, null=True)  # Field name made lowercase.
    listening_score = models.IntegerField(db_column='Listening_Score', blank=True, null=True)  # Field name made lowercase.
    reading_score = models.IntegerField(db_column='Reading_Score', blank=True, null=True)  # Field name made lowercase.
    score = models.IntegerField(db_column='Score', blank=True, null=True)  # Field name made lowercase.
    pass_yn = models.CharField(db_column='Pass_YN', max_length=135, blank=True, null=True)  # Field name made lowercase.
    effective_date = models.CharField(db_column='Effective_Date', max_length=135, blank=True, null=True)  # Field name made lowercase.
    duration = models.CharField(db_column='Duration', max_length=135, blank=True, null=True)  # Field name made lowercase.
    venue = models.CharField(db_column='Venue', max_length=135, blank=True, null=True)  # Field name made lowercase.
    trainer_assesor = models.CharField(db_column='Trainer_Assesor', max_length=135, blank=True, null=True)  # Field name made lowercase.

    class Meta:
        managed = False
        db_table = 'trs_training_and_test_record'


class ZzRecord(models.Model):
    id = models.BigAutoField(primary_key=True)
    employee_id = models.CharField(db_column='Employee_ID', max_length=135, blank=True, null=True)  # Field name made lowercase.
    name = models.CharField(db_column='Name', max_length=135, blank=True, null=True)  # Field name made lowercase.
    role = models.CharField(db_column='Role', max_length=135, blank=True, null=True)  # Field name made lowercase.

    class Meta:
        managed = False
        db_table = 'zz_record'

修改部分信息

pkid = models.IntegerField(primary_key=True)

特别提示

managed = False 意味着不修改数据库文章来源地址https://www.toymoban.com/news/detail-668996.html

到了这里,关于【Django】如何转化已有的数据表到Django模型--20230823的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • Django基础入门⑪:DjangoDjango数据表关联(一对一,一对多,多对多关系)

    🏘️🏘️个人简介:以山河作礼。 🎖️🎖️: Python领域新星创作者,CSDN实力新星认证,阿里云社区专家博主,CSDN内容合伙人 🎁🎁:Web全栈开发专栏:《Web全栈开发》免费专栏,欢迎阅读! 🎁🎁: 文章末尾扫描二维码可以加入粉丝交流群,不定期免费送书。 Django数据表关

    2024年02月12日
    浏览(63)
  • 通过一个实际例子说明Django中的数据库操作方法OneToOneField()的用法【数据表“一对一”关系】

    当我们在Django中定义一个模型时,可以使用 OneToOneField 来建立一个一对一的关系。这种关系表示两个模型之间的一种特殊关联,其中一个模型的实例只能与另一个模型的实例关联。 让我们以一个简单的示例来说明 OneToOneField 的用法。假设我们正在构建一个简单的博客应用,其

    2024年02月13日
    浏览(57)
  • 通过一个实际例子说明Django中的数据库操作方法法ForeignKey()的用法【数据表“一对多”关系】

    当使用Django进行数据库操作时,ForeignKey(外键)是一种非常有用的字段类型。它允许在数据库表之间创建关联关系,类似于其他数据库系统中的外键概念。通过ForeignKey字段,我们可以建立一个模型与另一个模型的一对多关系。 以下是一个实际例子,使用ForeignKey字段在Djang

    2024年02月12日
    浏览(56)
  • Doris(二) -- 基本概念和数据表模型

    数据类型 字节 范围 TINYINT 1 字节 -2^7 + 1 ~ 2^7 - 1 SMALLINT 2 字节 -2^15 + 1 ~ 2^15 - 1 INT 4 字节 -2^31 + 1 ~ 2^31 - 1 BIGINT 8 字节 -2^63 + 1 ~ 2^63 - 1 LARGEINT 16 字节 -2^127 + 1 ~ 2^127 - 1 FLOAT 4 字节 支持科学计数法 DOUBLE 12 字节 支持科学计数法 DECIMAL[(precision, scale)] 16 字节 保证精度的小数类型。默

    2024年02月06日
    浏览(41)
  • 数据分析-Pandas如何整合多张数据表

    数据表,时间序列数据在数据分析建模中很常见,例如天气预报,空气状态监测,股票交易等金融场景。数据分析过程中表格重整,重新调整,重塑数据表是很重要的技巧,此处选择Titanic数据,以及巴黎、伦敦欧洲城市空气质量监测 N O 2 NO_2 N O 2 ​ 数据作为样例。 数据分析

    2024年01月17日
    浏览(42)
  • wordpress数据表中标签和分类如何区分?

    wordpress中标签和分类是什么关系怎么区分?最后有一个群的网友告诉了我文章ID和标签ID的关系是放在了wp_term_relationships表中,然后我百度了下这个表的结构和相关介绍,发现果然如此,先把文章保存起来: wp_term_relationships表是WordPress自带的数据表之一,是用来描述WP分类关系

    2024年02月13日
    浏览(46)
  • 如何将Excel数据导入到MS SQL Server已定义的数据表中

    1. 前提:已经在SQL Server中定义了所要导入数据的表(如stock,salvaging和out_stock三张表)的结构。 2. 如图,选择要导入数据的数据库(例如dlqx数据库),右键-任务-导入数据。  2. 进入向导后,点击“下一步”。  3. (1)选择 数据源 ,这里选择Microsoft Excel,如图所示 (2)点击

    2024年02月04日
    浏览(44)
  • 【JaveWeb教程】(18) MySQL数据库开发之 MySQL数据库设计-DDL 如何查询、创建、使用、删除数据库数据表 详细代码示例讲解

    下面我们就正式的进入到SQL语句的学习,在学习之前先给大家介绍一下我们要开发一个项目,整个开发流程是什么样的,以及在流程当中哪些环节会涉及到数据库。 2.1 项目开发流程 需求文档: 在我们开发一个项目或者项目当中的某个模块之前,会先会拿到产品经理给我们提

    2024年01月25日
    浏览(104)
  • 【QT性能优化】QT性能优化之QT6框架高性能模型视图代理框架千万级数据表分页查询优化

    QT性能优化之QT6框架高性能模型视图代理框架千万级数据表分页查询优化 简介 本文介绍了QT模型视图代理框架中的QT表格控件和QT数据库模块中的QT数据库查询模型结合使用的一个应用实践案例:QT高性能表格控件分页展示千万行数据。本文介绍了这个应用实践案例的运行效果

    2024年02月14日
    浏览(53)
  • 数据库实验2 创建数据表修改数据表和删除数据表

    实验2 创建数据表修改数据表和删除数据表 实验类型: ●验证性实验  ○综合性实验  ○设计性实验 实验目的:      (1)了解数据表的结构特点。      (2)掌握表中列定义时所用到的各种数据类型。      (3)学会使用企业管理器(即MSSMS-----Microsoft SQL Server Manag

    2024年02月07日
    浏览(81)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包