Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7889131
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T06:01:03+00:00 2026-06-03T06:01:03+00:00

SQLalchemy gives me the following warning when I use a Numeric column with an

  • 0

SQLalchemy gives me the following warning when I use a Numeric column with an SQLite database engine.

SAWarning: Dialect sqlite+pysqlite does not support Decimal objects natively

I’m trying to figure out the best way to have pkgPrice = Column(Numeric(12,2)) in SQLalchemy while still using SQLite.

This question [1] How to convert Python decimal to SQLite numeric? shows a way to use sqlite3.register_adapter(D, adapt_decimal) to have SQLite receive and return Decimal, but store Strings, but I don’t know how to dig into the SQLAlchemy core to do this yet. Type Decorators look like the right approach but I don’t grok them yet.

Does anyone have a SQLAlchemy Type Decorator Recipe that will have Numeric or Decimal numbers in the SQLAlchemy model, but store them as strings in SQLite?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T06:01:04+00:00Added an answer on June 3, 2026 at 6:01 am
    from decimal import Decimal as D
    import sqlalchemy.types as types
    
    
    class SqliteNumeric(types.TypeDecorator):
        impl = types.String
    
        def load_dialect_impl(self, dialect):
            return dialect.type_descriptor(types.VARCHAR(100))
    
        def process_bind_param(self, value, dialect):
            return str(value)
    
        def process_result_value(self, value, dialect):
            return D(value)
    
    
    # can overwrite the imported type name
    # @note: the TypeDecorator does not guarantie the scale and precision.
    # you can do this with separate checks
    Numeric = SqliteNumeric
    class T(Base):
        __tablename__ = "t"
        id = Column(Integer, primary_key=True, nullable=False, unique=True)
        value = Column(Numeric(12, 2), nullable=False)
        # value = Column(SqliteNumeric(12, 2), nullable=False)
    
        def __init__(self, value):
            self.value = value
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I use SqlAlchemy to connect to my database backend and make heavy use of
SQLAlchemy seems really heavyweight if all I use is MySQL. Why are convincing reasons
I'm using sqlalchemy (with sqlite for now, but this may change later) to build
I am using SQLAlchemy + Pyramid to operate on my database. However, there are
What is the sqlalchemy equivalent column type for 'money' and 'OID' column types in
I am trying to use pyramid beaker in Pyramid framework and its just not
Using SQLAlchemy, an Engine object is created like this: from sqlalchemy import create_engine engine
I'm using Pyramid and SQLAlchemy, but the following simplified code: u = u\u201C m
SqlAlchemy newbie question: Base = declarative_base() class A(Base): __tablename__ = 'as' id = Column(Integer,
I have a SQLite database. According to this answer you need version 3.6.19+, which

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.