Numeric type without scale? Oracle

199 views
Skip to first unread message

jr

unread,
Oct 1, 2019, 9:28:45 AM10/1/19
to sqlalchemy


When the sqlalchemy Numeric type is used with default parameters, in an Oracle DB this generates the NUMBER type with empty precision but scale set to zero, which has the effect that only integer values can be saved.

 

My goal is to use the Oracle NUMBER type with empty scale in order to save decimal values with 'arbitrary' scale.

 

Which sqlalchemy column type do I have to use in order to generate an Oracle NUMBER type without precision and scale?


Thanks!

Mike Bayer

unread,
Oct 1, 2019, 9:35:25 AM10/1/19
to noreply-spamdigest via sqlalchemy
Hi there -

you can use sqlalchemy.dialects.oracle.NUMBER directly:

from sqlalchemy import Column
from sqlalchemy import MetaData
from sqlalchemy import Table
from sqlalchemy.dialects import oracle
from sqlalchemy.dialects.oracle import NUMBER
from sqlalchemy.schema import CreateTable


t = Table('t', MetaData(), Column('x', NUMBER()))

print(CreateTable(t).compile(dialect=oracle.dialect()))


CREATE TABLE t (
x NUMBER
)
--
SQLAlchemy -
The Python SQL Toolkit and Object Relational Mapper
 
 
To post example code, please provide an MCVE: Minimal, Complete, and Verifiable Example. See http://stackoverflow.com/help/mcve for a full description.
---
You received this message because you are subscribed to the Google Groups "sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+...@googlegroups.com.

jr

unread,
Oct 1, 2019, 10:17:26 AM10/1/19
to sqlalchemy
That worked perfectly, thank you so much for your help!
To unsubscribe from this group and stop receiving emails from it, send an email to sqlal...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages