본문 바로가기
  • 콩's 코딩노트

Python57

Python MySQL Connector를 이용해 delete하기 - delete메소드 pip install flask pip install flask-restful pip install mysql-connector-python 미리 설치할 라이브러리 use mysql; create user 'recipe_user'@'%' identified by '1q2w3e4r'; grant all on recipe_db.* to 'recipe_user'@'%'; 먼저 특정 유저만 DB에 접속할 수 있도록 새로운 계정을 만듬. import mysql.connector def get_connection(): connection = mysql.connector. connect( host = 'host.ctttsro2er9u.ap-northeast-2.rds.amazonaws.com', database = .. 2022. 6. 19.
Python MySQL Connector를 이용해 update하기 - put 메소드 pip install flask pip install flask-restful pip install mysql-connector-python 미리 설치할 라이브러리 use mysql; create user 'recipe_user'@'%' identified by '1q2w3e4r'; grant all on recipe_db.* to 'recipe_user'@'%'; 먼저 특정 유저만 DB에 접속할 수 있도록 새로운 계정을 만듬. import mysql.connector def get_connection(): connection = mysql.connector. connect( host = 'host.ctttsro2er9u.ap-northeast-2.rds.amazonaws.com', database = .. 2022. 6. 19.
Python MySQL Connector를 이용해 select하기 - get 메소드 pip install flask pip install flask-restful pip install mysql-connector-python 미리 설치할 라이브러리 use mysql; create user 'recipe_user'@'%' identified by '1q2w3e4r'; grant all on recipe_db.* to 'recipe_user'@'%'; 먼저 특정 유저만 DB에 접속할 수 있도록 새로운 계정을 만듬. import mysql.connector def get_connection(): connection = mysql.connector. connect( host = 'host.ctttsro2er9u.ap-northeast-2.rds.amazonaws.com', database = .. 2022. 6. 19.
Python MySQL Connector를 이용해 insert 하기 - port 메소드 pip install flask pip install flask-restful pip install mysql-connector-python 미리 설치할 라이브러리 use mysql; create user 'recipe_user'@'%' identified by '1q2w3e4r'; grant all on recipe_db.* to 'recipe_user'@'%'; 먼저 특정 유저만 DB에 접속할 수 있도록 새로운 계정을 만듬. import mysql.connector def get_connection(): connection = mysql.connector. connect( host = 'host.ctttsro2er9u.ap-northeast-2.rds.amazonaws.com', database = .. 2022. 6. 19.
Restful API에 대해 REST는 프로토콜이나 표준이 아닌 아키텍처 원칙 세트이다. RESTful API를 통해 요청이 수행될 때 RESTful API는 리소스 상태에 대한 표현을 요청자에게 전송합니다. 이 정보 또는 표현은 HTTP: JSON(Javascript Object Notation), HTML, XLT 또는 일반 텍스트를 통해 몇 가지 형식으로 전송됩니다. 보통은 JSON이 사용 언어와 상관이 없을 뿐 아니라 인간과 머신이 모두 읽을 수 있기 때문에 가장 널리 사용됩니다. REST는 다음과 같은 3가지로 구성이 되어있다. 자원(Resource) : HTTP URI 자원에 대한 행위(Verb) : HTTP Method 자원에 대한 행위의 내용 (Representations) : HTTP Message 1. 자원(Res.. 2022. 6. 19.
Python Flask에서, Resource 클래스를 이용한 API 서버 개발하기 API를 만들기 위한 클래스 작성법에 대해 알아보자. class(클래스)란? 변수와 함수로 구성된 묶음이다. 클래스는 상속이 가능하다는 특징이 있다. API를 만들기 위한 클래스는, flask_restful 라이브러리의 Resource 클래스를 상속해서 만들어야 한다. from flask import Flask from flask_restful import Api from resources.recipe import RecipeListResource from resources.recipe_info import RecipeResource app = Flask(__name__) api = Api(app) # 경로와 리소스(API 코드)를 연결한다. api.add_resource(RecipeListResourc.. 2022. 6. 17.