언어/Python
-
[Pymysql] 파이썬으로 Database 연결하는법언어/Python 2023. 1. 4. 15:09
조회하는 테이블내용 #1. install + import pymysql #터미널에서 pip install pymysql import pymysql if __name__ == '__main__': conn = "" cursor = "" #1. MariaDB연결 : pymysql.connect conn = pymysql.connect(host='localhost', port=포트번호, user='root', password='비밀번호', db='intern', charset='utf8') #2. 커서생성 cursor = conn.cursor() #3. sql문 입력 sql = "select INTN_NAME from intern_info" #4. sql문 실행 cursor.execute(sql) #5. 데이..
-
[FastAPI]client-server 데이터 주고받기 && 422 에러언어/Python 2022. 12. 28. 15:41
이 둘은 한 프로젝트 안에 있다 RestClient import requests import json class RestClient: def restapi_post(self, url, body): try: headers = {'Content-Type': 'application/json', 'charset': 'UTF-8', 'Accept': '*/*'} response = requests.post(url, headers=headers, data=json.dumps(body, ensure_ascii=False, indent="\t", default=str)) return response except Exception as err: raise def restapi_get(self, url): try: hea..
-
[JSON/Python]TypeError: Object of type datetime is not JSON serializable언어/Python 2022. 12. 27. 11:36
json.dumps(날짜타입의 데이터) 를 할 경우 TypeError: Object of type datetime is not JSON serializable 이라는 에러가 계속 났다. json이 해당 못 읽는거라는데, default=str을 추가해줬더니 해당 에러가 사라졌다. *body에 들어가는게 python 딕셔너리타입의 데이터였고, 거기에 datetime이 몇 개있었다.
-
[fastapi]tutorial 따라하기언어/Python 2022. 12. 16. 10:31
1. async, await? 2. Enum? https://docs.python.org/3/library/enum.html enum — Support for enumerations Source code: Lib/enum.py Important: This page contains the API reference information. For tutorial information and discussion of more advanced topics, see Basic Tutorial, Advanced Tutorial, Enum Co... docs.python.org https://docs.python.org/3/howto/enum.html#enum-class-differences Enum HOWTO An ..
-
[python/javascript] input ID vs NAME vs VALUE언어/Python 2022. 12. 12. 18:05
https://velog.io/@dongeranguk/input-%ED%83%9C%EA%B7%B8-id%EC%99%80-name%EC%9D%98-%EC%B0%A8%EC%9D%B4 input 태그 id와 name의 차이 document.all.id.valueid.valuedocument.getElementById("폼 id").valueid 속성은 page 안에서 중복으로 사용할 수 없으며, 주로 JavaScript에서 다루기 위해 지정한다.name 속성으로도 JavaScript를 통 velog.io name은 action 태그의 파라미터로 넘기는데에만 필요하고, id는 실제 구분을 위한 고유값이다. name은 중복이 가능하나 id는 중복이 되면 안된다. https://okky.kr/articles/645..