Example #1
0
__author__ = 'zhaoyifei'

from etl.tools import column_type_transform
import json

if __name__ == "__main__":
    print(
        column_type_transform.arrayTrans([12, 232, 334, 42, 532, 236, 17,
                                          218]))
    print(column_type_transform.arrayTrans(['1', '2', '3', '4', '5']))
    print(column_type_transform.arrayTrans(['1a', '2a', '3a', '4a', '5a']))
    print(column_type_transform.arrayTrans(['a', 'a', 'a', 'a', 'a']))
    print(column_type_transform.booleanTrans(True))
    print(column_type_transform.booleanTrans('True'))
    print(column_type_transform.booleanTrans(False))
    print(column_type_transform.booleanTrans('False'))
    print(column_type_transform.booleanTrans('aa'))
    print(column_type_transform.booleanTrans('false'))
    print(column_type_transform.floatTrans(1.2))
    print(column_type_transform.floatTrans(1.0))
    print(column_type_transform.floatTrans(1))
    print(column_type_transform.floatTrans('1.3'))
    print(column_type_transform.floatTrans('1.'))
    print(column_type_transform.floatTrans('.3'))
    print(column_type_transform.floatTrans('d'))
    print(column_type_transform.floatTrans({'a': 2}))
    print(column_type_transform.integerTrans(1.0))
    print(column_type_transform.integerTrans(1.3))
    print(column_type_transform.integerTrans(1.9))
    print(column_type_transform.integerTrans(1))
    print(column_type_transform.integerTrans('1'))
__author__ = 'zhaoyifei'

from etl.tools import column_type_transform
import json

if __name__ == "__main__":
    print(column_type_transform.arrayTrans([12, 232, 334, 42, 532, 236, 17, 218]))
    print(column_type_transform.arrayTrans(['1', '2', '3', '4', '5']))
    print(column_type_transform.arrayTrans(['1a', '2a', '3a', '4a', '5a']))
    print(column_type_transform.arrayTrans(['a', 'a', 'a', 'a', 'a']))
    print(column_type_transform.booleanTrans(True))
    print(column_type_transform.booleanTrans('True'))
    print(column_type_transform.booleanTrans(False))
    print(column_type_transform.booleanTrans('False'))
    print(column_type_transform.booleanTrans('aa'))
    print(column_type_transform.booleanTrans('false'))
    print(column_type_transform.floatTrans(1.2))
    print(column_type_transform.floatTrans(1.0))
    print(column_type_transform.floatTrans(1))
    print(column_type_transform.floatTrans('1.3'))
    print(column_type_transform.floatTrans('1.'))
    print(column_type_transform.floatTrans('.3'))
    print(column_type_transform.floatTrans('d'))
    print(column_type_transform.floatTrans({'a':2}))
    print(column_type_transform.integerTrans(1.0))
    print(column_type_transform.integerTrans(1.3))
    print(column_type_transform.integerTrans(1.9))
    print(column_type_transform.integerTrans(1))
    print(column_type_transform.integerTrans('1'))
    print(column_type_transform.integerTrans('d'))
    print(column_type_transform.integerTrans({'a':2}))
Example #3
0
        cur.execute("SELECT count(*) FROM log;")
        rows = cur.fetchall()        # all rows in table
        for row in rows:
            print(row)

    with pgaccess.PgAccess() as pga:
        pga.execFunc(selectLog)

    insertSql = 'INSERT INTO test(\
                m_id, price, birthday, "isDeletec", num, flo, tags, ints)\
        VALUES (%s, %s, %s, %s, %s, %s, %s, %s);'

    sqlL = []
    print(arrayTrans([123, 34, 43, 54, 12]))
    sqlL.append((insertSql, (None, str('1,000,000'),
                            timeStampTrans(1450576800), booleanTrans(False),
                            integerTrans(12), None,
                            arrayTrans(['ad', 'dfd', 'dfs', 'fsd', 'ewrew']),
                            arrayTrans([123, 34, 43, 54, 12])
                            )
                 )
                )

    sqlL.append((insertSql, (str('dfd'), None,
                            timeStampTrans(1450576800), booleanTrans(False),
                            integerTrans(12), floatTrans(1.23455),
                            arrayTrans(['ad', 'dfd', 'dfs', 'fsd', 'ewrew']),
                            None
                            )
                 )
                )