Пример #1
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)
Пример #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
    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
    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
 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
    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())