def get_datatype(value):
    """ Determine most appropriate SQLite datatype for storing value.

        SQLite has only four underlying storage classes: integer, real,
        text, and blob.

        For compatibility with other flavors of SQL, it's possible to
        define columns with more specific datatypes (e.g. 'char',
        'date'), but since these are still mapped to the underlying
        storage classes there's not much point in using them when
        generating native SQLite SQL.

        Therefore, this function takes an incoming value and attempts
        to guess the best SQLite datatype for storing it. This can
        then be used to help decide the schema of the column where the
        value will be stored.

        It defaults to the text datatype, not the super-general blob
        datatype, because read_csv reads each row in as text rather
        than binary data.

        Unlike in other SQL flavors, misdefining a column's datatype
        affinity is not fatal, because in the end any type of value
        can be stored in any column. In the end, the datatype
        returned by this function is just a suggestion for SQLite.

        See:
           * https://www.sqlite.org/datatype3.html
           * http://ericsink.com/mssql_mobile/data_types.html
           * http://www.techonthenet.com/sqlite/datatypes.php
    """
    try:
        int(value)
        return 'INTEGER'
    except ValueError:
        try:
           float(value)
           return 'REAL'
        except ValueError:
            return 'TEXT'