Skip to content

Instantly share code, notes, and snippets.

@klinkin
Created October 2, 2012 20:58
Show Gist options
  • Save klinkin/3823258 to your computer and use it in GitHub Desktop.
Save klinkin/3823258 to your computer and use it in GitHub Desktop.
1234
# -*- coding: utf-8 -*-
from shwzkpfmobile.models import Base, BaseNode, DBSession
from shwzkpfmobile.models.content.materials import Feed
from sqlalchemy import schema, types, orm, sql
import sqlamp
import datetime
def initial_db(db):
id = schema.Column(types.Integer, primary_key=True)
time_created = schema.Column(types.DateTime, default=datetime.datetime.now)
feed_type = schema.Column(types.Integer, nullable=False)
parent_id = schema.Column(types.Integer, schema.ForeignKey('schwzkpf_feeds.id'))
origin_id = schema.Column(types.Integer)
only_choosed = schema.Column(types.Boolean, default=False)
title = schema.Column(types.Unicode(length=500))
owner_id = schema.Column(types.Integer, schema.ForeignKey("schwrzkpf_users.id"), nullable=True, default=0)
material_obects = [
{'feed_type': 2, 'owner_id': 0, 'parent_id': None, "title": u"КАТАЛОГ"},
{'feed_type': 2, 'owner_id': 0, 'parent_id': None, "title": u"САЛОНЫ"},
{'feed_type': 2, 'owner_id': 0, 'parent_id': None, "title": u"ТРЕНДЫ"},
{'feed_type': 2, 'owner_id': 0, 'parent_id': None, "title": u"НОВОСТИ"},
{'feed_type': 2, 'owner_id': 0, 'parent_id': None, "title": u"СОВЕТЫ"},
]
for el in material_obects:
obj = Feed(**el)
db.add(obj)
db.commit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment