sql/update_db_0_13_to_0_16.2.py
changeset 63 7b721b427b73
child 65 c838c80d5ba7
equal deleted inserted replaced
62:39b2dab4f939 63:7b721b427b73
       
     1 #! /usr/bin/env python
       
     2 
       
     3 import sys, os, os.path, time, tempfile, uuid
       
     4 
       
     5 sys.path.append(os.path.dirname(os.path.abspath(__file__))+"/../web/")
       
     6 
       
     7 from django.core.management import setup_environ
       
     8 from franceculture import settings
       
     9 
       
    10 setup_environ(settings)
       
    11 
       
    12 from franceculture.settings import *
       
    13 
       
    14 from ldt.ldt_utils.model import Content, Media
       
    15 
       
    16 
       
    17 from django.db import connection, transaction
       
    18 cursor = connection.cursor()
       
    19 
       
    20 # Data retrieval operation - no commit required
       
    21 cursor.execute("SELECT id,external_id, videopath, src FROM ldt_utils_content", None)
       
    22 
       
    23 
       
    24 for row in cursor.fetchall():
       
    25     new_media = Media(external_id = row[1], videopath=row[2], src=row[3])
       
    26     new_media.save()
       
    27     
       
    28     content = Content.objects.get(id=row[0])
       
    29     content.media_obj = new_media
       
    30     
       
    31     content.save()
       
    32