Debian Codegraph @

petl/test/io/test_db_inference.py

raw
1 import pytest
2
3 from petl.io.db_create import make_sqlalchemy_column
4
5 try:
6 import sqlalchemy # noqa: F401
7 except ImportError as e:
8 pytest.skip('SKIP generic DB inference tests: %s' % e, allow_module_level=True)
9 else:
10 from sqlalchemy import JSON, Integer
11
12 def test_json_inference():
13 data = [{'a': 1}, {'b': 2}, None]
14 col = make_sqlalchemy_column(data, 'payload')
15 assert col.name == 'payload'
16 assert isinstance(col.type, JSON)
17
18 def test_int_inference():
19 col = make_sqlalchemy_column([1, 2, 3], 'n')
20 assert col.name == 'n'
21 assert isinstance(col.type, Integer)