How to use the sqlobject.col function in SQLObject

To help you get started, we’ve selected a few SQLObject examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github stoq / stoq / external / sqlobject / sqlite / sqliteconnection.py View on Github external
def guessClass(self, t):
        t = t.upper()
        if t.find('INT') >= 0:
            return col.IntCol, {}
        elif t.find('TEXT') >= 0 or t.find('CHAR') >= 0 or t.find('CLOB') >= 0:
            return col.StringCol, {'length': 2**32-1}
        elif t.find('BLOB') >= 0:
            return col.BLOBCol, {"length": 2**32-1}
        elif t.find('REAL') >= 0 or t.find('FLOAT') >= 0:
            return col.FloatCol, {}
        elif t.find('DECIMAL') >= 0:
            return col.DecimalCol, {'size': None, 'precision': None}
        elif t.find('BOOL') >= 0:
            return col.BoolCol, {}
        else:
            return col.Col, {}
github stoq / stoq / external / sqlobject / firebird / firebirdconnection.py View on Github external
return col.IntCol, {}
        elif t == 'integer':       # -2,147,483,648 to +2,147,483,647, 32 bits
            return col.IntCol, {}
        elif t == 'bigint':        # -2^63 to 2^63-1 or -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807, 64 bits
            return col.IntCol, {}
        elif t == 'float':         # 32 bits, 3.4x10^-38 to 3.4x10^38, 7 digit precision (7 significant decimals)
            return col.FloatCol, {}
        elif t == 'double':        # 64 bits, 1.7x10^-308 to 1.7x10^308, 15 digit precision (15 significant decimals)
            return col.FloatCol, {}
        elif t == 'numeric':        # Numeric and Decimal are internally stored as smallint, integer or bigint depending on the size. They can handle up to 18 digits.
            if (not flength or not fscale): # If neither PRECISION nor SCALE are specified, Firebird/InterBase defines the column as INTEGER instead of NUMERIC and stores only the integer portion of the value
                return col.IntCol, {}
            return col.DecimalCol, {'size': flength, 'precision': fscale} # check if negative values are allowed for fscale

        elif t == 'decimal': # Numeric and Decimal are internally stored as smallint, integer or bigint depending on the size. They can handle up to 18 digits.
            return col.DecimalCol, {'size': flength, 'precision': fscale} # check if negative values are allowed for fscale
        elif t == 'date': # 32 bits, 1 Jan 100. to 29 Feb 32768.
            return col.DateCol, {}
        elif t == 'time': # 32 bits, 00:00 to 23:59.9999
            return col.TimeCol, {}
        elif t == 'timestamp': # 64 bits, 1 Jan 100 to 28 Feb 32768.
            return col.DateTimeCol, {}
        elif t == 'char': # 32767 bytes
            if fCharset and (fCharset != "NONE"):
                return col.UnicodeCol, {'length': flength, 'varchar': False, 'dbEncoding': fCharset}
            elif self.dbEncoding:
                return col.UnicodeCol, {'length': flength, 'varchar': False, 'dbEncoding': self.dbEncoding}
            else:
                return col.StringCol, {'length': flength, 'varchar': False}
        elif t == 'varchar': # 32767 bytes
            if fCharset and (fCharset != "NONE"):
                return col.UnicodeCol, {'length': flength, 'varchar': True, 'dbEncoding': fCharset}
github sqlobject / sqlobject / sqlobject / mssql / mssqlconnection.py View on Github external
def guessClass(self, t, size, precision, scale):
        """
        Here we take raw values coming out of syscolumns
        and map to SQLObject class types.

        """
        if t.startswith('int'):
            return col.IntCol, {}
        elif t.startswith('varchar'):
            if self.usingUnicodeStrings:
                return col.UnicodeCol, {'length': size}
            return col.StringCol, {'length': size}
        elif t.startswith('char'):
            if self.usingUnicodeStrings:
                return col.UnicodeCol, {'length': size,
                                        'varchar': False}
            return col.StringCol, {'length': size,
                                   'varchar': False}
        elif t.startswith('datetime'):
            return col.DateTimeCol, {}
        elif t.startswith('decimal'):
            # be careful for awkward naming
            return col.DecimalCol, {'size': precision,
                                    'precision': scale}
github stoq / stoq / external / sqlobject / maxdb / maxdbconnection.py View on Github external
def guessClass(self, t, flength, fscale=None):
        """
        An internal method that tries to figure out what Col subclass
        is appropriate given whatever introspective information is
        available -- both very database-specific.
        """
        if t in self._numericTypes:
            return col.IntCol, {}
        # The type returned by the sapdb library for LONG is
        # SapDB_LongReader To get the data call the read member with
        # desired size (default =-1 means get all)

        elif t.find('LONG') != -1:
            return col.StringCol, {'length': flength,
                                   'varchar': False}
        elif t in self._dateTypes:
            return col.DateTimeCol, {}
        elif t == 'FIXED':
            return CurrencyCol,{'size':flength,
                                'precision':fscale}
        else:
            return col.Col, {}
github stoq / stoq / external / sqlobject / mysql / mysqlconnection.py View on Github external
elif t.startswith('tinytext'):
            return col.StringCol, {"length": 2**8-1, "varchar": True}
        elif t.startswith('blob'):
            return col.BLOBCol, {"length": 2**16-1}
        elif t.startswith('text'):
            return col.StringCol, {"length": 2**16-1, "varchar": True}
        elif t.startswith('mediumblob'):
            return col.BLOBCol, {"length": 2**24-1}
        elif t.startswith('mediumtext'):
            return col.StringCol, {"length": 2**24-1, "varchar": True}
        elif t.startswith('longblob'):
            return col.BLOBCol, {"length": 2**32}
        elif t.startswith('longtext'):
            return col.StringCol, {"length": 2**32, "varchar": True}
        else:
            return col.Col, {}
github stoq / stoq / external / sqlobject / mssql / mssqlconnection.py View on Github external
def guessClass(self, t, size, precision, scale):
        """
            Here we take raw values coming out of syscolumns and map to SQLObject class types.
        """
        if t.startswith('int'):
            return col.IntCol, {}
        elif t.startswith('varchar'):
            if self.usingUnicodeStrings:
                return col.UnicodeCol, {'length': size}
            return col.StringCol, {'length': size}
        elif t.startswith('char'):
            if self.usingUnicodeStrings:
                return col.UnicodeCol, {'length': size,
                                       'varchar': False}
            return col.StringCol, {'length': size,
                                   'varchar': False}
        elif t.startswith('datetime'):
            return col.DateTimeCol, {}
        elif t.startswith('decimal'):
            return col.DecimalCol, {'size': precision, # be careful for awkward naming
                                   'precision': scale}
        else:
            return col.Col, {}
github stoq / stoq / external / sqlobject / mssql / mssqlconnection.py View on Github external
if kw.get("ncli"):
                    conn_str = "Provider=SQLNCLI;"
                else:
                    conn_str = "Provider=SQLOLEDB;"

                conn_str += "Data Source=%s;Initial Catalog=%s;"

                # MSDE does not allow SQL server login
                if kw.get("sspi"):
                    conn_str += "Integrated Security=SSPI;Persist Security Info=False"
                    self.make_conn_str = lambda keys: [conn_str % (keys.host, keys.db)]
                else:
                    conn_str += "User Id=%s;Password=%s"
                    self.make_conn_str = lambda keys: [conn_str % (keys.host, keys.db, keys.user, keys.password)]

                col.popKey(kw, "sspi")
                col.popKey(kw, "ncli")

            except ImportError: # raise the exceptions other than ImportError for adodbapi absence
                import pymssql as sqlmodule
                self.dbconnection = sqlmodule.connect
                sqlmodule.Binary = lambda st: str(st)
                # don't know whether pymssql uses unicode
                self.usingUnicodeStrings = False
                self.make_conn_str = lambda keys:  \
                       ["", keys.user, keys.password, keys.host, keys.db]
        self.autoCommit=int(autoCommit)
        self.host = host
        self.db = db
        self.user = user
        self.password = password
        self.limit_re = re.compile('^\s*(select )(.*)', re.IGNORECASE)
github stoq / stoq / external / sqlobject / mssql / mssqlconnection.py View on Github external
def guessClass(self, t, size, precision, scale):
        """
            Here we take raw values coming out of syscolumns and map to SQLObject class types.
        """
        if t.startswith('int'):
            return col.IntCol, {}
        elif t.startswith('varchar'):
            if self.usingUnicodeStrings:
                return col.UnicodeCol, {'length': size}
            return col.StringCol, {'length': size}
        elif t.startswith('char'):
            if self.usingUnicodeStrings:
                return col.UnicodeCol, {'length': size,
                                       'varchar': False}
            return col.StringCol, {'length': size,
                                   'varchar': False}
        elif t.startswith('datetime'):
            return col.DateTimeCol, {}
        elif t.startswith('decimal'):
            return col.DecimalCol, {'size': precision, # be careful for awkward naming
                                   'precision': scale}
        else: