Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the difference between BIGINT and BigInteger in SQLAlchemy?

BigInteger

class BigInteger(Integer):

    """A type for bigger ``int`` integers.

    Typically generates a ``BIGINT`` in DDL, and otherwise acts like
    a normal :class:`.Integer` on the Python side.

    """

    __visit_name__ = 'big_integer'

BIGINT

class BIGINT(BigInteger):

    """The SQL BIGINT type."""

    __visit_name__ = 'BIGINT'

But Column(BigInteger) and Column(BIGINT) can both work, both define a bigint in postgresql. How to distinguish them?

like image 413
Libraco Avatar asked Mar 05 '23 18:03

Libraco


1 Answers

They both work, but the BIGINT has to be imported from a specific dialect, eg postgres in your case. If you change your database to eg. mysql, you might have problems. With BigInteger sqlalchemy with take care of the mapping, depending on the database you are using, so you should prefer this one.

like image 181
blue_note Avatar answered Apr 27 '23 16:04

blue_note