avatar

Catalog
实体-联系图自动生成系统

实体联系图自动生成系统

关于pygraphviz的依赖

Code
1
2
3
4
5
apt install graphviz-dev

sudo pip install pygraphviz --install-option="--include-path=/usr/local/include/graphviz/" --install-option="--library-path=/usr/local/lib/graphviz"
# 在安装的时候指定graphviz的路径
在windows下要指定
  • json与实体之间的转换
  • json表示联系

pygraphviz 接受 dot ,改为 graphviz 应无变化

Code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
![Alt Text](http://webtools.company_domain.net/graphviz/?
digraph G {
aize ="4,4";
main [shape=box];
main -> parse [weight=8];
parse -> execute;
main -> init [style=dotted];
main -> cleanup;
execute -> { make_string; printf};
init -> make_string;
edge [color=red];
main -> printf [style=bold,label="100 times"];
make_string [label="make a string"];
node [shape=box,style=filled,color=".7 .3 1.0"];
execute -> compare;
})

使用gunicorn部署flask项目

  1. 安装gunicorn

  2. 假设flask的app.p

    python
    1
    2
    3
    4
    5
    6
    from flask import Flask
    app = Flask(__name__)

    @app.route("/")
    def hello():
    return "Hello World!"
  3. 在shell中输入

    python
    1
    2
    gunicorn -w 3 -b 127.0.0.1:5000 app:app
    #第一个为flask项目实例所在的包,第二个为app生成的flask项目

sqlalchemy 涉及到的知识点

sqlalchemy.ext.declarative.declarative_base

sqlalchemy.orm.relationship

引用到的包

python
1
2
3
4
5
from sqlalchemy import Table, Column, Integer, ForeignKey
from sqlalchemy.orm import relationship
from sqlalchemy.ext.declarative import declarative_base

Base = declarative_base()

一对多

父节点和子节点

python
1
2
3
4
5
6
7
8
9
class Parent(Base):
__tablename__ = 'parent'
id = Column(Integer, primary_key=True)
children = relationship("Child")

class Child(Base):
__tablename__ = 'child'
id = Column(Integer, primary_key=True)
parent_id = Column(Integer, ForeignKey('parent.id'))

metadata型,declarative型

column属性:

数据类型:

关系

json to base

属性:

json
1
{"tablename":"base","columns":"[{"name":"xxx":}]","relationships":"xxx"}

gua

Author: Jacob
Link: http://yoursite.com/2020/01/31/%E5%AE%9E%E4%BD%93-%E8%81%94%E7%B3%BB%E5%9B%BE%E8%87%AA%E5%8A%A8%E7%94%9F%E6%88%90%E7%B3%BB%E7%BB%9F/
Copyright Notice: All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stating additionally.
Donate
  • 微信
    微信
  • 支付寶
    支付寶