sql/update_db_0_13_to_0_16.2.py
author ymh <ymh.work@gmail.com>
Tue, 21 Sep 2010 06:34:28 +0200
changeset 63 7b721b427b73
child 65 c838c80d5ba7
permissions -rw-r--r--
new version and some update

#! /usr/bin/env python

import sys, os, os.path, time, tempfile, uuid

sys.path.append(os.path.dirname(os.path.abspath(__file__))+"/../web/")

from django.core.management import setup_environ
from franceculture import settings

setup_environ(settings)

from franceculture.settings import *

from ldt.ldt_utils.model import Content, Media


from django.db import connection, transaction
cursor = connection.cursor()

# Data retrieval operation - no commit required
cursor.execute("SELECT id,external_id, videopath, src FROM ldt_utils_content", None)


for row in cursor.fetchall():
    new_media = Media(external_id = row[1], videopath=row[2], src=row[3])
    new_media.save()
    
    content = Content.objects.get(id=row[0])
    content.media_obj = new_media
    
    content.save()