반응형
Python 의 기본 ORM 을 사용한다면, id 필드를 통한 unique 값 생성이 기본이다. 기본값은 INT인데, INT로 생성할 경우 최대 생성 가능한 컬럼이 2,147,483,647 까지 가능하다. 만약 이값을 넘어간다면, 추후 BIGINT로 변경하는 것을 고려해야 한다.
따라서 되도록 초기 구성시 INT보다 큰 값을 제공하는 BIGINT를 이용하기를 추천한다.
https://docs.sqlalchemy.org/en/14/core/type_basics.html
Column and Data Types — SQLAlchemy 1.4 Documentation
A type for fixed precision numbers, such as NUMERIC or DECIMAL. This type returns Python decimal.Decimal objects by default, unless the Numeric.asdecimal flag is set to False, in which case they are coerced to Python float objects. Note The Numeric type is
docs.sqlalchemy.org
위 문서에 보면, BigInteger를 통해서 선언이 가능하다.
class Asecurity(Base):
__tablename__ = "asecurity_table"
id = Column(BigInteger, primary_key=True, index=True)
date = Column(DateTime)
그리고 실제 T-SQL을 통한 DB생성은 BIGINT 명을 이용할 수 있다.
CREATE TABLE `asecurity_table` (
`id` BIGINT NOT NULL AUTO_INCREMENT,
`date` DATETIME NULL DEFAULT NULL,
'Python' 카테고리의 다른 글
Python - string 문자열 원하는 구분자 기준으로 나누기 (0) | 2021.06.28 |
---|---|
Python - Http Retry 및 while 을 통한 반복문 (0) | 2021.06.16 |
Python - subprocess, Popen, call차이 그리고 WorkDirectory 변경 (0) | 2021.05.24 |
Django - MySQL/MariaDB 연결하기 (0) | 2021.03.24 |
PYTHON pip install fails with “connection error: [SSL: CERTIFICATE_VERIFY_FAILED] (0) | 2020.10.06 |
댓글0