コード例 #1
0
ファイル: tests.py プロジェクト: dwarventech/csv2sqlite
    def setUpClass(cls):
        cls.args = Objectifier({
            'input': 'test/test4.csv',
            'mapping': 'test/test4.json',
            'output': 'tmp/test4.sqlite3',
            'default_mapping_action': 'ignore',
            'csv_has_title_columns': True,
        })

        libcsv2sqlite.csv_to_sqlite3(cls.args)
コード例 #2
0
    def setUpClass(cls):
        cls.args = Objectifier({
            'input': 'test/test4.csv',
            'mapping': 'test/test4.json',
            'output': 'tmp/test4.sqlite3',
            'default_mapping_action': 'ignore',
            'csv_has_title_columns': True,
        })

        libcsv2sqlite.csv_to_sqlite3(cls.args)
コード例 #3
0
ファイル: tests.py プロジェクト: dwarventech/csv2sqlite
    def test_csv_to_sqlite3(self):
        libcsv2sqlite.csv_to_sqlite3(self.args)

        # If there was no pk, there should be 3 results
        self.assertEqual(dbutils.count('taxi'), 2)
コード例 #4
0
ファイル: tests.py プロジェクト: dwarventech/csv2sqlite
    def test_csv_to_sqlite3(self):
        libcsv2sqlite.csv_to_sqlite3(self.args)

        self.assertTrue(dbutils.table_exists('person'))
        self.assertEqual(dbutils.count('person'), 4)
コード例 #5
0
ファイル: tests.py プロジェクト: dwarventech/csv2sqlite
 def test_column_generation(self):
     libcsv2sqlite.csv_to_sqlite3(self.args)
     self.assertTrue(dbutils.column_is_pk('trucks', 'truck_id'))
コード例 #6
0
    def test_csv_to_sqlite3(self):
        libcsv2sqlite.csv_to_sqlite3(self.args)

        # If there was no pk, there should be 3 results
        self.assertEqual(dbutils.count('taxi'), 2)
コード例 #7
0
    def test_csv_to_sqlite3(self):
        libcsv2sqlite.csv_to_sqlite3(self.args)

        self.assertTrue(dbutils.table_exists('person'))
        self.assertEqual(dbutils.count('person'), 4)
コード例 #8
0
 def test_column_generation(self):
     libcsv2sqlite.csv_to_sqlite3(self.args)
     self.assertTrue(dbutils.column_is_pk('trucks', 'truck_id'))
コード例 #9
0
ファイル: csv2sqlite.py プロジェクト: dwarventech/csv2sqlite
    required=False,
    default='db.sqlite'
)

parser.add_argument(
    '--mapping', '-m',
    metavar='mapping.json',
    type=str,
    help='a mapping file allows to control how data is imported. For more details, refer to the examples',
    required=False
)

parser.add_argument(
    '--csv-has-title-columns', '-t',
    help="indicates if the first line in the CSV file contains title columns to be used as column tables. In the case of mapped foreign keys, they'll be used as table names",
    action='store_true',
    required=False,
    default=False
)

parser.add_argument(
    '--default-mapping-action', '-d',
    help='default action to take if an unmapped column (not in mapping file) is found while importing',
    type=str,
    required=False,
    default='ignore',
    choices=['import', 'ignore']
)

libcsv2sqlite.csv_to_sqlite3(parser.parse_args())
コード例 #10
0
parser.add_argument(
    '--mapping',
    '-m',
    metavar='mapping.json',
    type=str,
    help=
    'a mapping file allows to control how data is imported. For more details, refer to the examples',
    required=False)

parser.add_argument(
    '--csv-has-title-columns',
    '-t',
    help=
    "indicates if the first line in the CSV file contains title columns to be used as column tables. In the case of mapped foreign keys, they'll be used as table names",
    action='store_true',
    required=False,
    default=False)

parser.add_argument(
    '--default-mapping-action',
    '-d',
    help=
    'default action to take if an unmapped column (not in mapping file) is found while importing',
    type=str,
    required=False,
    default='ignore',
    choices=['import', 'ignore'])

libcsv2sqlite.csv_to_sqlite3(parser.parse_args())