Skip to content

sqlalchemy

choisungwook edited this page May 19, 2021 · 3 revisions

개요

  • flask sqlalchmey 사용 메뉴얼

엔티티 생성

참고자료: https://flask-sqlalchemy.palletsprojects.com/en/2.x/models/#simple-example

  • db.Model을 상속하여 class 정의
from flask_sqlalchemy import SQLAlchemy

db = SQLAlchemy()

class Example(db.Models):
    __tablename__  = 'user'

    id = db.Column(db.Integer, primary_key=True)
    email = db.Column(db.String(50), unique=True, nullable=False)
    password = db.Column(db.String(20), nullable=False)

    ...

select, where

참고자료: https://flask-sqlalchemy.palletsprojects.com/en/2.x/queries/#querying-records

  • 객체.filter_by(컬럼1=검색조건).first()
example = Example()
example.query.filter_by(email=email)).first()
쿠버네티스
도커
aws
리눅스
개발

파이썬

테라폼
기타
Clone this wiki locally