Beispiel #1
0
 def tst_parameter_types01(p_tst_bigint, p_tst_int, p_tst_smallint,
                           p_tst_bit, p_tst_money, p_tst_numeric,
                           p_tst_float, p_tst_real, p_tst_date,
                           p_tst_timestamp, p_tst_time6, p_tst_char,
                           p_tst_varchar):
     return StaticDataLayer.execute_sp_none(
         "select tst_parameter_types01(%s::bigint, %s::int, %s::smallint, %s::bit(4), %s::money, %s::numeric, %s::numeric, %s::real, %s::date, %s::timestamp, %s::timestamp, %s::char, %s::varchar)",
         p_tst_bigint, p_tst_int, p_tst_smallint, p_tst_bit, p_tst_money,
         p_tst_numeric, p_tst_float, p_tst_real, p_tst_date,
         p_tst_timestamp, p_tst_time6, p_tst_char, p_tst_varchar)
Beispiel #2
0
    def get_bulk_insert_table_columns_info(self):
        """
        Gets the column names and column types of the current table for bulk insert.
        """
        query = """
select 1 from
information_schema.TABLES
where TABLE_SCHEMA = database()
and   TABLE_NAME   = '%s'""" % self._table_name

        table_is_non_temporary = StaticDataLayer.execute_rows(query)

        if len(table_is_non_temporary) == 0:
            query = 'call %s()' % self._routine_name
            StaticDataLayer.execute_sp_none(query)

        query = "describe `%s`" % self._table_name
        columns = StaticDataLayer.execute_rows(query)

        tmp_column_types = []
        tmp_fields = []

        n1 = 0
        for column in columns:
            p = re.compile('(\\w+)')
            c_type = p.findall(column['Type'])
            tmp_column_types.append(c_type[0])
            tmp_fields.append(column['Field'])
            n1 += 1

        n2 = len(self._columns)

        if len(table_is_non_temporary) == 0:
            query = "drop temporary table `%s`" % self._table_name
            StaticDataLayer.execute_none(query)

        if n1 != n2:
            raise Exception(
                "Number of fields %d and number of columns %d don't match." %
                (n1, n2))

        self._columns_types = tmp_column_types
        self._fields = tmp_fields
    def get_bulk_insert_table_columns_info(self):
        """
        Gets the column names and column types of the current table for bulk insert.
        """
        query = """
select 1 from
information_schema.TABLES
where TABLE_SCHEMA = database()
and   TABLE_NAME   = '%s'""" % self._table_name

        table_is_non_temporary = StaticDataLayer.execute_rows(query)

        if len(table_is_non_temporary) == 0:
            query = 'call %s()' % self._routine_name
            StaticDataLayer.execute_sp_none(query)

        query = "describe `%s`" % self._table_name
        columns = StaticDataLayer.execute_rows(query)

        tmp_column_types = []
        tmp_fields = []

        n1 = 0
        for column in columns:
            p = re.compile('(\\w+)')
            c_type = p.findall(column['Type'])
            tmp_column_types.append(c_type[0])
            tmp_fields.append(column['Field'])
            n1 += 1

        n2 = len(self._columns)

        if len(table_is_non_temporary) == 0:
            query = "drop temporary table `%s`" % self._table_name
            StaticDataLayer.execute_none(query)

        if n1 != n2:
            raise Exception("Number of fields %d and number of columns %d don't match." % (n1, n2))

        self._columns_types = tmp_column_types
        self._fields = tmp_fields
Beispiel #4
0
 def tst_test_none_with_lob(p_count, p_blob):
     return StaticDataLayer.execute_sp_none(
         "select tst_test_none_with_lob(%s::bigint, %s::bytea)", p_count,
         p_blob)
Beispiel #5
0
 def tst_test_none(p_count):
     return StaticDataLayer.execute_sp_none(
         "select tst_test_none(%s::bigint)", p_count)