Table des matières

Ce travail est repris et complété par l'outil WebNeL.

Modèles Django des bases de données

Les sources ci dessous son issues de fichiers créés par la commande

python manage.py inspectdb

Ils reprennent la structure des bases de données nel, pour être utilisées dans une application Django.

C'est assez brut comme info, mais directement utilisable par un dev.

Base nel

from django.db import models
 
class Domain(models.Model):
    domain_id = models.AutoField(primary_key=True)
    domain_name = models.CharField(unique=True, max_length=32)
    status = models.CharField(max_length=13)
    patch_version = models.IntegerField()
    backup_patch_url = models.CharField(max_length=255, blank=True, null=True)
    patch_urls = models.TextField(blank=True, null=True)
    login_address = models.CharField(max_length=255)
    session_manager_address = models.CharField(max_length=255)
    ring_db_name = models.CharField(max_length=255)
    web_host = models.CharField(max_length=255)
    web_host_php = models.CharField(max_length=255)
    description = models.CharField(max_length=200, blank=True, null=True)
 
    class Meta:
        db_table = 'domain'
 
 
class Permission(models.Model):
    permissionid = models.AutoField(db_column='PermissionId', primary_key=True)  # Field name made lowercase.
    uid = models.IntegerField(db_column='UId')  # Field name made lowercase.
    domainid = models.IntegerField(db_column='DomainId')  # Field name made lowercase.
    shardid = models.IntegerField(db_column='ShardId')  # Field name made lowercase.
    accessprivilege = models.CharField(db_column='AccessPrivilege', max_length=19)  # Field name made lowercase.
 
    class Meta:
        db_table = 'permission'
 
 
class Shard(models.Model):
    shardid = models.IntegerField(db_column='ShardId', primary_key=True)  # Field name made lowercase.
    domain_id = models.IntegerField()
    wsaddr = models.CharField(db_column='WsAddr', max_length=64, blank=True, null=True)  # Field name made lowercase.
    nbplayers = models.IntegerField(db_column='NbPlayers', blank=True, null=True)  # Field name made lowercase.
    name = models.CharField(db_column='Name', max_length=255, blank=True, null=True)  # Field name made lowercase.
    online = models.IntegerField(db_column='Online', blank=True, null=True)  # Field name made lowercase.
    version = models.CharField(db_column='Version', max_length=64)  # Field name made lowercase.
    fixedsessionid = models.IntegerField(db_column='FixedSessionId')  # Field name made lowercase.
    state = models.CharField(db_column='State', max_length=13)  # Field name made lowercase.
    motd = models.TextField(db_column='MOTD')  # Field name made lowercase.
 
    class Meta:
        db_table = 'shard'
 
 
class User(models.Model):
    uid = models.AutoField(db_column='UId', primary_key=True)  # Field name made lowercase.
    login = models.CharField(db_column='Login', unique=True, max_length=64)  # Field name made lowercase.
    password = models.CharField(db_column='Password', max_length=106, blank=True, null=True)  # Field name made lowercase.
    shardid = models.IntegerField(db_column='ShardId')  # Field name made lowercase.
    state = models.CharField(db_column='State', max_length=7)  # Field name made lowercase.
    privilege = models.CharField(db_column='Privilege', max_length=255)  # Field name made lowercase.
    groupname = models.CharField(db_column='GroupName', max_length=255)  # Field name made lowercase.
    firstname = models.CharField(db_column='FirstName', max_length=255)  # Field name made lowercase.
    lastname = models.CharField(db_column='LastName', max_length=255)  # Field name made lowercase.
    birthday = models.CharField(db_column='Birthday', max_length=32)  # Field name made lowercase.
    gender = models.IntegerField(db_column='Gender')  # Field name made lowercase.
    country = models.CharField(db_column='Country', max_length=2)  # Field name made lowercase.
    email = models.CharField(db_column='Email', unique=True, max_length=255)  # Field name made lowercase.
    address = models.CharField(db_column='Address', max_length=255)  # Field name made lowercase.
    city = models.CharField(db_column='City', max_length=100)  # Field name made lowercase.
    postalcode = models.CharField(db_column='PostalCode', max_length=10)  # Field name made lowercase.
    usstate = models.CharField(db_column='USState', max_length=2)  # Field name made lowercase.
    chat = models.CharField(db_column='Chat', max_length=2)  # Field name made lowercase.
    betakeyid = models.IntegerField(db_column='BetaKeyId')  # Field name made lowercase.
    cachedcoupons = models.CharField(db_column='CachedCoupons', max_length=255)  # Field name made lowercase.
    profileaccess = models.CharField(db_column='ProfileAccess', max_length=45, blank=True, null=True)  # Field name made lowercase.
    level = models.IntegerField(db_column='Level')  # Field name made lowercase.
    currentfunds = models.IntegerField(db_column='CurrentFunds')  # Field name made lowercase.
    idbilling = models.CharField(db_column='IdBilling', max_length=255)  # Field name made lowercase.
    community = models.CharField(db_column='Community', max_length=2)  # Field name made lowercase.
    newsletter = models.IntegerField(db_column='Newsletter')  # Field name made lowercase.
    account = models.CharField(db_column='Account', max_length=64)  # Field name made lowercase.
    choicesublength = models.IntegerField(db_column='ChoiceSubLength')  # Field name made lowercase.
    currentsublength = models.CharField(db_column='CurrentSubLength', max_length=255)  # Field name made lowercase.
    valididbilling = models.IntegerField(db_column='ValidIdBilling')  # Field name made lowercase.
    gmid = models.IntegerField(db_column='GMId')  # Field name made lowercase.
    extendedprivilege = models.CharField(db_column='ExtendedPrivilege', max_length=128)  # Field name made lowercase.
    toolsgroup = models.CharField(db_column='ToolsGroup', max_length=20)  # Field name made lowercase.
    unsubscribe = models.DateField(db_column='Unsubscribe')  # Field name made lowercase.
    subdate = models.DateTimeField(db_column='SubDate')  # Field name made lowercase.
    subip = models.CharField(db_column='SubIp', max_length=20)  # Field name made lowercase.
    securepassword = models.CharField(db_column='SecurePassword', max_length=32)  # Field name made lowercase.
    lastinvoiceemailcheck = models.DateField(db_column='LastInvoiceEmailCheck')  # Field name made lowercase.
    fromsource = models.CharField(db_column='FromSource', max_length=8)  # Field name made lowercase.
    validmerchantcode = models.CharField(db_column='ValidMerchantCode', max_length=13)  # Field name made lowercase.
    pbc = models.IntegerField(db_column='PBC')  # Field name made lowercase.
    apikeyseed = models.CharField(db_column='ApiKeySeed', max_length=8, blank=True, null=True)  # Field name made lowercase.
 
    class Meta:
        db_table = 'user'

Base kring

from django.db import models
 
 
class Characters(models.Model):
    char_id = models.IntegerField(primary_key=True)
    char_name = models.CharField(max_length=20)
    user_id = models.IntegerField()
    guild_id = models.IntegerField()
    best_combat_level = models.IntegerField()
    home_mainland_session_id = models.IntegerField()
    ring_access = models.CharField(max_length=63)
    race = models.CharField(max_length=8)
    civilisation = models.CharField(max_length=9)
    cult = models.CharField(max_length=9)
    current_session = models.IntegerField()
    rrp_am = models.IntegerField()
    rrp_masterless = models.IntegerField()
    rrp_author = models.IntegerField()
    newcomer = models.IntegerField()
    creation_date = models.DateTimeField()
    last_played_date = models.DateTimeField()
 
    class Meta:
        managed = False
        db_table = 'characters'
        unique_together = (('char_name', 'home_mainland_session_id'),)
 
 
class Folder(models.Model):
    id = models.AutoField(db_column='Id', primary_key=True)  # Field name made lowercase.
    owner = models.IntegerField()
    title = models.CharField(max_length=40)
    comments = models.TextField()
 
    class Meta:
        managed = False
        db_table = 'folder'
 
 
class FolderAccess(models.Model):
    id = models.AutoField(db_column='Id', primary_key=True)  # Field name made lowercase.
    folder_id = models.IntegerField()
    user_id = models.IntegerField()
 
    class Meta:
        managed = False
        db_table = 'folder_access'
 
 
class GuildInvites(models.Model):
    id = models.AutoField(db_column='Id', primary_key=True)  # Field name made lowercase.
    session_id = models.IntegerField()
    guild_id = models.IntegerField()
 
    class Meta:
        managed = False
        db_table = 'guild_invites'
 
 
class Guilds(models.Model):
    guild_id = models.IntegerField(primary_key=True)
    guild_name = models.CharField(max_length=50)
    shard_id = models.IntegerField()
 
    class Meta:
        managed = False
        db_table = 'guilds'
 
 
class JournalEntry(models.Model):
    id = models.AutoField(db_column='Id', primary_key=True)  # Field name made lowercase.
    session_id = models.IntegerField()
    author = models.IntegerField()
    type = models.CharField(max_length=11)
    text = models.TextField()
    time_stamp = models.DateTimeField()
 
    class Meta:
        managed = False
        db_table = 'journal_entry'
 
 
class KnownUsers(models.Model):
    id = models.AutoField(db_column='Id', primary_key=True)  # Field name made lowercase.
    owner = models.IntegerField()
    targer_user = models.IntegerField()
    targer_character = models.IntegerField()
    relation_type = models.CharField(max_length=12)
    comments = models.CharField(max_length=255)
 
    class Meta:
        managed = False
        db_table = 'known_users'
 
 
class MfsErasedMailSeries(models.Model):
    erased_char_id = models.IntegerField()
    erased_char_name = models.CharField(max_length=32)
    erased_series = models.AutoField(primary_key=True)
    erase_date = models.DateTimeField()
 
    class Meta:
        managed = False
        db_table = 'mfs_erased_mail_series'
 
 
class MfsGuildThread(models.Model):
    thread_id = models.AutoField(primary_key=True)
    guild_id = models.IntegerField()
    topic = models.CharField(max_length=255)
    author_name = models.CharField(max_length=32)
    last_post_date = models.DateTimeField()
    post_count = models.IntegerField()
 
    class Meta:
        managed = False
        db_table = 'mfs_guild_thread'
 
 
class MfsGuildThreadMessage(models.Model):
    thread_id = models.IntegerField()
    author_name = models.CharField(max_length=32)
    date = models.DateTimeField()
    content = models.TextField()
 
    class Meta:
        managed = False
        db_table = 'mfs_guild_thread_message'
 
 
class MfsMail(models.Model):
    sender_name = models.CharField(max_length=32)
    subject = models.CharField(max_length=250)
    date = models.DateTimeField()
    status = models.CharField(max_length=9)
    dest_char_id = models.IntegerField()
    erase_series = models.IntegerField()
    content = models.TextField()
 
    class Meta:
        managed = False
        db_table = 'mfs_mail'
 
 
class Outlands(models.Model):
    session_id = models.AutoField(primary_key=True)
    island_name = models.TextField()
    billing_instance_id = models.IntegerField()
    anim_session_id = models.IntegerField()
 
    class Meta:
        managed = False
        db_table = 'outlands'
 
 
class PlayerRating(models.Model):
    id = models.AutoField(db_column='Id', primary_key=True)  # Field name made lowercase.
    scenario_id = models.IntegerField()
    session_id = models.IntegerField()
    rate_fun = models.IntegerField()
    rate_difficulty = models.IntegerField()
    rate_accessibility = models.IntegerField()
    rate_originality = models.IntegerField()
    rate_direction = models.IntegerField()
    author = models.IntegerField()
    rating = models.IntegerField()
    comments = models.TextField()
    time_stamp = models.DateTimeField()
 
    class Meta:
        managed = False
        db_table = 'player_rating'
 
 
class RingUsers(models.Model):
    user_id = models.IntegerField(primary_key=True)
    user_name = models.CharField(unique=True, max_length=20)
    user_type = models.CharField(max_length=12)
    current_session = models.IntegerField()
    current_activity = models.CharField(max_length=7)
    current_status = models.CharField(max_length=10)
    public_level = models.CharField(max_length=9)
    account_type = models.CharField(max_length=9)
    content_access_level = models.CharField(max_length=20)
    description = models.TextField()
    lang = models.CharField(max_length=7)
    cookie = models.CharField(max_length=30)
    current_domain_id = models.IntegerField()
    pioneer_char_id = models.IntegerField()
    current_char = models.IntegerField()
    add_privileges = models.CharField(max_length=64)
 
    class Meta:
        managed = False
        db_table = 'ring_users'
 
 
class Scenario(models.Model):
    md5 = models.CharField(max_length=64)
    title = models.CharField(max_length=32)
    description = models.TextField()
    author = models.CharField(max_length=32)
    rrp_total = models.IntegerField()
    anim_mode = models.CharField(max_length=13)
    language = models.CharField(max_length=11)
    orientation = models.CharField(max_length=18)
    level = models.CharField(max_length=4)
    allow_free_trial = models.IntegerField()
 
    class Meta:
        managed = False
        db_table = 'scenario'
 
 
class ScenarioDesc(models.Model):
    session_id = models.IntegerField(primary_key=True)
    parent_scenario = models.IntegerField()
    description = models.TextField()
    relation_to_parent = models.CharField(max_length=13)
    title = models.CharField(unique=True, max_length=40)
    num_player = models.IntegerField()
    content_access_level = models.CharField(max_length=20)
 
    class Meta:
        managed = False
        db_table = 'scenario_desc'
 
 
class SessionLog(models.Model):
    id = models.IntegerField(primary_key=True)
    scenario_id = models.IntegerField()
    rrp_scored = models.IntegerField()
    scenario_point_scored = models.IntegerField()
    time_taken = models.IntegerField()
    participants = models.TextField()
    launch_date = models.DateTimeField()
    owner = models.CharField(max_length=32)
    guild_name = models.CharField(max_length=50, blank=True, null=True)
 
    class Meta:
        managed = False
        db_table = 'session_log'
 
 
class SessionParticipant(models.Model):
    id = models.AutoField(db_column='Id', primary_key=True)  # Field name made lowercase.
    session_id = models.IntegerField()
    char_id = models.IntegerField()
    status = models.CharField(max_length=19)
    kicked = models.IntegerField()
    session_rated = models.IntegerField()
 
    class Meta:
        managed = False
        db_table = 'session_participant'
 
 
class Sessions(models.Model):
    session_id = models.AutoField(primary_key=True)
    session_type = models.CharField(max_length=11)
    title = models.CharField(max_length=40)
    owner = models.IntegerField()
    plan_date = models.DateTimeField()
    start_date = models.DateTimeField()
    description = models.TextField()
    orientation = models.CharField(max_length=18)
    level = models.CharField(max_length=4)
    rule_type = models.CharField(max_length=10)
    access_type = models.CharField(max_length=10)
    state = models.CharField(max_length=10)
    host_shard_id = models.IntegerField()
    subscription_slots = models.IntegerField()
    reserved_slots = models.IntegerField()
    free_slots = models.IntegerField()
    estimated_duration = models.CharField(max_length=9)
    final_duration = models.IntegerField()
    folder_id = models.IntegerField()
    lang = models.CharField(max_length=20)
    icone = models.CharField(max_length=70)
    anim_mode = models.CharField(max_length=13)
    race_filter = models.CharField(max_length=36)
    religion_filter = models.CharField(max_length=29)
    guild_filter = models.CharField(max_length=16, blank=True, null=True)
    shard_filter = models.CharField(max_length=351)
    level_filter = models.CharField(max_length=29)
    subscription_closed = models.IntegerField()
    newcomer = models.IntegerField()
 
    class Meta:
        managed = False
        db_table = 'sessions'
 
 
class Shard(models.Model):
    shard_id = models.IntegerField(primary_key=True)
    wsonline = models.IntegerField(db_column='WSOnline')  # Field name made lowercase.
    motd = models.TextField(db_column='MOTD')  # Field name made lowercase.
    oldstate = models.CharField(db_column='OldState', max_length=13)  # Field name made lowercase.
    requiredstate = models.CharField(db_column='RequiredState', max_length=13)  # Field name made lowercase.
 
    class Meta:
        managed = False
        db_table = 'shard'