반응형
psql
-
[psycopg2] postgresql oid 에 대한 텍스트 가져오는 쿼리Programming Language/Python 2021. 11. 15. 18:05
postgresql 에는 oid (object identifier) 가 있는데 테이블의 타입도 oid 로 관리하고 있다. 만약 python 에서 psycopg2 라이브러리를 사용한다면, 아래처럼 타입을 oid 로 받게 된다. import psycopg2 conn = psycopg2.connect() cur = conn.cursor() cur.execute("select A, B from TEST") cur.description # (Column(name='A', type_code=20), Column(name='B', type_code=25)) 이때, 해당 oid 에 대한 타입명을 알고 싶으면 아래 쿼리를 사용하면 알 수 있다. # psql select 20::regtype::text; text ----..