1

I want write project using database library (SQLAlchemy). When I use SQLite, all works good, but when I deploy project on server (Heroku with Postgres plugin), It doesn't work. This is code for my database:

class UserBase(Base):
    __tablename__ = 'users'

    id = Column(Integer, Sequence('user_id_seq'), primary_key=True)
    nickname = Column(String(50), unique=True, nullable=False)
    server = Column(Integer)
    language = Column(String(2))

    def __repr__(self):
        return "<UserBase(nickname='%s', server='%s', language='%s')>" % \
            (self.nickname, self.server, self.language)

I have engine & Base variable:

engine = create_engine(os.environ.get('DATABASE_URL'))
Base = declarative_base()

In DATABASE_URL link to base on Heroku(Postgres). For create database I write in Interactive Python Console:

from user_base import Base, engine
Base.metadata.create_all(engine)

After these manipulations in the server logs it gives this:

sqlalchemy.exc.DataError: (psycopg2.errors.NumericValueOutOfRange) integer out of range

How to fix problem? If you needs in info, asking.

1 Answer 1

1

I set type of server as String, indicated that the server is a string and this is helped me.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.