Libraco
Libraco

Reputation: 151

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?

Upvotes: 6

Views: 8405

Answers (1)

blue note
blue note

Reputation: 29071

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.

Upvotes: 9

Related Questions