Commit b43d4c01 authored by Administrator's avatar Administrator

[FEAT] Commenting manual declaration of Node() with sqla.

parent c5bfdd03
...@@ -44,7 +44,7 @@ def model_repr(modelname): ...@@ -44,7 +44,7 @@ def model_repr(modelname):
# map the Django models found in node.models to SQLAlchemy models # map the Django models found in node.models to SQLAlchemy models
for model_name, model in models.__dict__.items(): for model_name, model in models.__dict__.items():
if hasattr(model, '_meta') : if hasattr(model, '_meta'):
table_name = model._meta.db_table table_name = model._meta.db_table
if hasattr(Base.classes, table_name): if hasattr(Base.classes, table_name):
sqla_model = getattr(Base.classes, table_name) sqla_model = getattr(Base.classes, table_name)
...@@ -63,15 +63,19 @@ from sqlalchemy.schema import Column, ForeignKey ...@@ -63,15 +63,19 @@ from sqlalchemy.schema import Column, ForeignKey
from sqlalchemy.dialects.postgresql import JSONB from sqlalchemy.dialects.postgresql import JSONB
from sqlalchemy.orm import relationship, aliased from sqlalchemy.orm import relationship, aliased
class Node(Base): #class Node(Base):
__tablename__ = 'node_node' # __tablename__ = 'node_node'
id = Column(Integer, primary_key=True) # __table_args__ = {'auto_load':True, 'extend_existing':True}
user_id = Column(Integer, ForeignKey('auth_user.id', ondelete='CASCADE'), index=True, nullable=False) # id = Column(Integer, primary_key=True)
type_id = Column(Integer, ForeignKey('node_nodetype.id', ondelete='CASCADE'), index=True, nullable=False) # user_id = Column(Integer, ForeignKey('auth_user.id', ondelete='CASCADE'), index=True, nullable=False)
name = Column(String(255)) # type_id = Column(Integer, ForeignKey('node_nodetype.id', ondelete='CASCADE'), index=True, nullable=False)
language_id = Column(Integer, ForeignKey('node_language.id', ondelete='CASCADE'), index=True, nullable=False) # name = Column(String(255))
date = Column(DateTime(), default=datetime.utcnow, nullable=True) # language_id = Column(Integer, ForeignKey('node_language.id', ondelete='CASCADE'), index=True, nullable=False)
hyperdata = Column(JSONB, default={}, nullable=False) # date = Column(DateTime(), default=datetime.utcnow, nullable=True)
# hyperdata = Column(JSONB, default={}, nullable=False)
#
# def __repr__(self):
# return '<Id %r>' % self.id
# debugging tool, to translate SQLAlchemy queries to string # debugging tool, to translate SQLAlchemy queries to string
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment