Python sqlalchemy.sql.sqltypes.Float() Examples
The following are 15
code examples of sqlalchemy.sql.sqltypes.Float().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
sqlalchemy.sql.sqltypes
, or try the search function
.
Example #1
Source File: test_sql.py From recruit with Apache License 2.0 | 6 votes |
def test_notna_dtype(self): if self.flavor == 'mysql': pytest.skip('Not applicable to MySQL legacy') cols = {'Bool': Series([True, None]), 'Date': Series([datetime(2012, 5, 1), None]), 'Int': Series([1, None], dtype='object'), 'Float': Series([1.1, None]) } df = DataFrame(cols) tbl = 'notna_dtype_test' df.to_sql(tbl, self.conn) assert self._get_sqlite_column_type(tbl, 'Bool') == 'INTEGER' assert self._get_sqlite_column_type(tbl, 'Date') == 'TIMESTAMP' assert self._get_sqlite_column_type(tbl, 'Int') == 'INTEGER' assert self._get_sqlite_column_type(tbl, 'Float') == 'REAL'
Example #2
Source File: test_sql.py From vnpy_crypto with MIT License | 6 votes |
def test_notna_dtype(self): if self.flavor == 'mysql': pytest.skip('Not applicable to MySQL legacy') cols = {'Bool': Series([True, None]), 'Date': Series([datetime(2012, 5, 1), None]), 'Int': Series([1, None], dtype='object'), 'Float': Series([1.1, None]) } df = DataFrame(cols) tbl = 'notna_dtype_test' df.to_sql(tbl, self.conn) assert self._get_sqlite_column_type(tbl, 'Bool') == 'INTEGER' assert self._get_sqlite_column_type(tbl, 'Date') == 'TIMESTAMP' assert self._get_sqlite_column_type(tbl, 'Int') == 'INTEGER' assert self._get_sqlite_column_type(tbl, 'Float') == 'REAL'
Example #3
Source File: test_sql.py From predictive-maintenance-using-machine-learning with Apache License 2.0 | 6 votes |
def test_notna_dtype(self): cols = {'Bool': Series([True, None]), 'Date': Series([datetime(2012, 5, 1), None]), 'Int': Series([1, None], dtype='object'), 'Float': Series([1.1, None]) } df = DataFrame(cols) tbl = 'notna_dtype_test' df.to_sql(tbl, self.conn) returned_df = sql.read_sql_table(tbl, self.conn) # noqa meta = sqlalchemy.schema.MetaData(bind=self.conn) meta.reflect() if self.flavor == 'mysql': my_type = sqltypes.Integer else: my_type = sqltypes.Boolean col_dict = meta.tables[tbl].columns assert isinstance(col_dict['Bool'].type, my_type) assert isinstance(col_dict['Date'].type, sqltypes.DateTime) assert isinstance(col_dict['Int'].type, sqltypes.Integer) assert isinstance(col_dict['Float'].type, sqltypes.Float)
Example #4
Source File: test_sql.py From predictive-maintenance-using-machine-learning with Apache License 2.0 | 6 votes |
def test_notna_dtype(self): if self.flavor == 'mysql': pytest.skip('Not applicable to MySQL legacy') cols = {'Bool': Series([True, None]), 'Date': Series([datetime(2012, 5, 1), None]), 'Int': Series([1, None], dtype='object'), 'Float': Series([1.1, None]) } df = DataFrame(cols) tbl = 'notna_dtype_test' df.to_sql(tbl, self.conn) assert self._get_sqlite_column_type(tbl, 'Bool') == 'INTEGER' assert self._get_sqlite_column_type(tbl, 'Date') == 'TIMESTAMP' assert self._get_sqlite_column_type(tbl, 'Int') == 'INTEGER' assert self._get_sqlite_column_type(tbl, 'Float') == 'REAL'
Example #5
Source File: test_sql.py From elasticintel with GNU General Public License v3.0 | 6 votes |
def test_notna_dtype(self): cols = {'Bool': Series([True, None]), 'Date': Series([datetime(2012, 5, 1), None]), 'Int': Series([1, None], dtype='object'), 'Float': Series([1.1, None]) } df = DataFrame(cols) tbl = 'notna_dtype_test' df.to_sql(tbl, self.conn) returned_df = sql.read_sql_table(tbl, self.conn) # noqa meta = sqlalchemy.schema.MetaData(bind=self.conn) meta.reflect() if self.flavor == 'mysql': my_type = sqltypes.Integer else: my_type = sqltypes.Boolean col_dict = meta.tables[tbl].columns assert isinstance(col_dict['Bool'].type, my_type) assert isinstance(col_dict['Date'].type, sqltypes.DateTime) assert isinstance(col_dict['Int'].type, sqltypes.Integer) assert isinstance(col_dict['Float'].type, sqltypes.Float)
Example #6
Source File: test_sql.py From elasticintel with GNU General Public License v3.0 | 6 votes |
def test_notna_dtype(self): if self.flavor == 'mysql': pytest.skip('Not applicable to MySQL legacy') cols = {'Bool': Series([True, None]), 'Date': Series([datetime(2012, 5, 1), None]), 'Int': Series([1, None], dtype='object'), 'Float': Series([1.1, None]) } df = DataFrame(cols) tbl = 'notna_dtype_test' df.to_sql(tbl, self.conn) assert self._get_sqlite_column_type(tbl, 'Bool') == 'INTEGER' assert self._get_sqlite_column_type(tbl, 'Date') == 'TIMESTAMP' assert self._get_sqlite_column_type(tbl, 'Int') == 'INTEGER' assert self._get_sqlite_column_type(tbl, 'Float') == 'REAL'
Example #7
Source File: test_sql.py From twitter-stock-recommendation with MIT License | 6 votes |
def test_notna_dtype(self): cols = {'Bool': Series([True, None]), 'Date': Series([datetime(2012, 5, 1), None]), 'Int': Series([1, None], dtype='object'), 'Float': Series([1.1, None]) } df = DataFrame(cols) tbl = 'notna_dtype_test' df.to_sql(tbl, self.conn) returned_df = sql.read_sql_table(tbl, self.conn) # noqa meta = sqlalchemy.schema.MetaData(bind=self.conn) meta.reflect() if self.flavor == 'mysql': my_type = sqltypes.Integer else: my_type = sqltypes.Boolean col_dict = meta.tables[tbl].columns assert isinstance(col_dict['Bool'].type, my_type) assert isinstance(col_dict['Date'].type, sqltypes.DateTime) assert isinstance(col_dict['Int'].type, sqltypes.Integer) assert isinstance(col_dict['Float'].type, sqltypes.Float)
Example #8
Source File: test_sql.py From twitter-stock-recommendation with MIT License | 6 votes |
def test_notna_dtype(self): if self.flavor == 'mysql': pytest.skip('Not applicable to MySQL legacy') cols = {'Bool': Series([True, None]), 'Date': Series([datetime(2012, 5, 1), None]), 'Int': Series([1, None], dtype='object'), 'Float': Series([1.1, None]) } df = DataFrame(cols) tbl = 'notna_dtype_test' df.to_sql(tbl, self.conn) assert self._get_sqlite_column_type(tbl, 'Bool') == 'INTEGER' assert self._get_sqlite_column_type(tbl, 'Date') == 'TIMESTAMP' assert self._get_sqlite_column_type(tbl, 'Int') == 'INTEGER' assert self._get_sqlite_column_type(tbl, 'Float') == 'REAL'
Example #9
Source File: test_sql.py From recruit with Apache License 2.0 | 5 votes |
def test_notna_dtype(self): cols = {'Bool': Series([True, None]), 'Date': Series([datetime(2012, 5, 1), None]), 'Int': Series([1, None], dtype='object'), 'Float': Series([1.1, None]) } df = DataFrame(cols) tbl = 'notna_dtype_test' df.to_sql(tbl, self.conn) returned_df = sql.read_sql_table(tbl, self.conn) # noqa meta = sqlalchemy.schema.MetaData(bind=self.conn) meta.reflect() if self.flavor == 'mysql': my_type = sqltypes.Integer else: my_type = sqltypes.Boolean col_dict = meta.tables[tbl].columns assert isinstance(col_dict['Bool'].type, my_type) assert isinstance(col_dict['Date'].type, sqltypes.DateTime) assert isinstance(col_dict['Int'].type, sqltypes.Integer) assert isinstance(col_dict['Float'].type, sqltypes.Float)
Example #10
Source File: test_sql.py From vnpy_crypto with MIT License | 5 votes |
def test_notna_dtype(self): cols = {'Bool': Series([True, None]), 'Date': Series([datetime(2012, 5, 1), None]), 'Int': Series([1, None], dtype='object'), 'Float': Series([1.1, None]) } df = DataFrame(cols) tbl = 'notna_dtype_test' df.to_sql(tbl, self.conn) returned_df = sql.read_sql_table(tbl, self.conn) # noqa meta = sqlalchemy.schema.MetaData(bind=self.conn) meta.reflect() if self.flavor == 'mysql': my_type = sqltypes.Integer else: my_type = sqltypes.Boolean col_dict = meta.tables[tbl].columns assert isinstance(col_dict['Bool'].type, my_type) assert isinstance(col_dict['Date'].type, sqltypes.DateTime) assert isinstance(col_dict['Int'].type, sqltypes.Integer) assert isinstance(col_dict['Float'].type, sqltypes.Float)
Example #11
Source File: test_sql.py From vnpy_crypto with MIT License | 5 votes |
def test_double_precision(self): V = 1.23456789101112131415 df = DataFrame({'f32': Series([V, ], dtype='float32'), 'f64': Series([V, ], dtype='float64'), 'f64_as_f32': Series([V, ], dtype='float64'), 'i32': Series([5, ], dtype='int32'), 'i64': Series([5, ], dtype='int64'), }) df.to_sql('test_dtypes', self.conn, index=False, if_exists='replace', dtype={'f64_as_f32': sqlalchemy.Float(precision=23)}) res = sql.read_sql_table('test_dtypes', self.conn) # check precision of float64 assert (np.round(df['f64'].iloc[0], 14) == np.round(res['f64'].iloc[0], 14)) # check sql types meta = sqlalchemy.schema.MetaData(bind=self.conn) meta.reflect() col_dict = meta.tables['test_dtypes'].columns assert str(col_dict['f32'].type) == str(col_dict['f64_as_f32'].type) assert isinstance(col_dict['f32'].type, sqltypes.Float) assert isinstance(col_dict['f64'].type, sqltypes.Float) assert isinstance(col_dict['i32'].type, sqltypes.Integer) assert isinstance(col_dict['i64'].type, sqltypes.BigInteger)
Example #12
Source File: test_sql.py From predictive-maintenance-using-machine-learning with Apache License 2.0 | 5 votes |
def test_double_precision(self): V = 1.23456789101112131415 df = DataFrame({'f32': Series([V, ], dtype='float32'), 'f64': Series([V, ], dtype='float64'), 'f64_as_f32': Series([V, ], dtype='float64'), 'i32': Series([5, ], dtype='int32'), 'i64': Series([5, ], dtype='int64'), }) df.to_sql('test_dtypes', self.conn, index=False, if_exists='replace', dtype={'f64_as_f32': sqlalchemy.Float(precision=23)}) res = sql.read_sql_table('test_dtypes', self.conn) # check precision of float64 assert (np.round(df['f64'].iloc[0], 14) == np.round(res['f64'].iloc[0], 14)) # check sql types meta = sqlalchemy.schema.MetaData(bind=self.conn) meta.reflect() col_dict = meta.tables['test_dtypes'].columns assert str(col_dict['f32'].type) == str(col_dict['f64_as_f32'].type) assert isinstance(col_dict['f32'].type, sqltypes.Float) assert isinstance(col_dict['f64'].type, sqltypes.Float) assert isinstance(col_dict['i32'].type, sqltypes.Integer) assert isinstance(col_dict['i64'].type, sqltypes.BigInteger)
Example #13
Source File: test_sql.py From elasticintel with GNU General Public License v3.0 | 5 votes |
def test_double_precision(self): V = 1.23456789101112131415 df = DataFrame({'f32': Series([V, ], dtype='float32'), 'f64': Series([V, ], dtype='float64'), 'f64_as_f32': Series([V, ], dtype='float64'), 'i32': Series([5, ], dtype='int32'), 'i64': Series([5, ], dtype='int64'), }) df.to_sql('test_dtypes', self.conn, index=False, if_exists='replace', dtype={'f64_as_f32': sqlalchemy.Float(precision=23)}) res = sql.read_sql_table('test_dtypes', self.conn) # check precision of float64 assert (np.round(df['f64'].iloc[0], 14) == np.round(res['f64'].iloc[0], 14)) # check sql types meta = sqlalchemy.schema.MetaData(bind=self.conn) meta.reflect() col_dict = meta.tables['test_dtypes'].columns assert str(col_dict['f32'].type) == str(col_dict['f64_as_f32'].type) assert isinstance(col_dict['f32'].type, sqltypes.Float) assert isinstance(col_dict['f64'].type, sqltypes.Float) assert isinstance(col_dict['i32'].type, sqltypes.Integer) assert isinstance(col_dict['i64'].type, sqltypes.BigInteger)
Example #14
Source File: test_sql.py From twitter-stock-recommendation with MIT License | 5 votes |
def test_double_precision(self): V = 1.23456789101112131415 df = DataFrame({'f32': Series([V, ], dtype='float32'), 'f64': Series([V, ], dtype='float64'), 'f64_as_f32': Series([V, ], dtype='float64'), 'i32': Series([5, ], dtype='int32'), 'i64': Series([5, ], dtype='int64'), }) df.to_sql('test_dtypes', self.conn, index=False, if_exists='replace', dtype={'f64_as_f32': sqlalchemy.Float(precision=23)}) res = sql.read_sql_table('test_dtypes', self.conn) # check precision of float64 assert (np.round(df['f64'].iloc[0], 14) == np.round(res['f64'].iloc[0], 14)) # check sql types meta = sqlalchemy.schema.MetaData(bind=self.conn) meta.reflect() col_dict = meta.tables['test_dtypes'].columns assert str(col_dict['f32'].type) == str(col_dict['f64_as_f32'].type) assert isinstance(col_dict['f32'].type, sqltypes.Float) assert isinstance(col_dict['f64'].type, sqltypes.Float) assert isinstance(col_dict['i32'].type, sqltypes.Integer) assert isinstance(col_dict['i64'].type, sqltypes.BigInteger)
Example #15
Source File: test_sql.py From recruit with Apache License 2.0 | 4 votes |
def test_double_precision(self): V = 1.23456789101112131415 df = DataFrame({'f32': Series([V, ], dtype='float32'), 'f64': Series([V, ], dtype='float64'), 'f64_as_f32': Series([V, ], dtype='float64'), 'i32': Series([5, ], dtype='int32'), 'i64': Series([5, ], dtype='int64'), }) df.to_sql('test_dtypes', self.conn, index=False, if_exists='replace', dtype={'f64_as_f32': sqlalchemy.Float(precision=23)}) res = sql.read_sql_table('test_dtypes', self.conn) # check precision of float64 assert (np.round(df['f64'].iloc[0], 14) == np.round(res['f64'].iloc[0], 14)) # check sql types meta = sqlalchemy.schema.MetaData(bind=self.conn) meta.reflect() col_dict = meta.tables['test_dtypes'].columns assert str(col_dict['f32'].type) == str(col_dict['f64_as_f32'].type) assert isinstance(col_dict['f32'].type, sqltypes.Float) assert isinstance(col_dict['f64'].type, sqltypes.Float) assert isinstance(col_dict['i32'].type, sqltypes.Integer) assert isinstance(col_dict['i64'].type, sqltypes.BigInteger)