Beispiel #1
0
    def test_ok_2(self):
        """
        Input csv file is plural
        """
        TEST_FILE_1 = "sqlite_write_test_1.csv"
        TEST_FILE_2 = "sqlite_write_test_2.csv"
        try:
            with open(TEST_FILE_1, "w", encoding="utf-8", newline="") as f:
                writer = csv.writer(f)
                writer.writerow(["No", "TEXT"])
                writer.writerow(["1", "A"])

            with open(TEST_FILE_2, "w", encoding="utf-8", newline="") as f:
                writer = csv.writer(f)
                writer.writerow(["No", "TEXT"])
                writer.writerow(["2", "B"])

            instance = self._create_instance(r"sqlite_write_test_.*.csv", True)
            instance.execute()

            adapter = SqliteAdapter()
            adapter.connect(self.DB_NAME)
            cur = adapter.fetch("SELECT * FROM %s" % self.TBL_NAME, row_factory=self._dict_factory)

            count = 0
            for row in cur:
                if count == 0:
                    assert row == {"No": "1", "TEXT": "A"}
                elif count == 1:
                    assert row == {"No": "2", "TEXT": "B"}
                count += 1

        finally:
            self._clean(self.DB_NAME)
            self._clean(TEST_FILE_1)
            self._clean(TEST_FILE_2)
Beispiel #2
0
 def __init__(self):
     super().__init__()
     self._sqlite_adptr = SqliteAdapter()
     self._dbname = None
     self._vacuum = False
Beispiel #3
0
 def __init__(self):
     super().__init__()
     self._sqlite_adptr = SqliteAdapter()
     self._dbname = None
     self._columns = []
Beispiel #4
0
 def setup_method(self, method):
     self._db_dir = os.path.join(env.BASE_DIR, "db")
     self._adptr = SqliteAdapter()