def test_create_by_file_encoded_an_set_runtime_path(self):
        self.filename = "b64pyshell.txt"
        runtime_path = "C:\\Users\\burtnolej"
        append_text_to_file(
            self.filename,
            "database_name:" + b64encode(self.database_name) + "\n")
        append_text_to_file(self.filename,
                            "table_name:" + b64encode(self.table_name) + "\n")
        append_text_to_file(self.filename,
                            "delete_flag:" + b64encode("False") + "\n")

        append_text_to_file(
            self.filename, "column_defns:" + "$$".join([
                b64encode(_name) + "^" + b64encode(_type)
                for _name, _type in self.column_defn
            ]) + "\n")
        DatabaseCreateTable.create_by_file(self.filename,
                                           runtime_path=runtime_path)

        database = Database(
            runtime_path + "\\" + self.database_name + ".sqlite", True)

        with database:
            self.assertTrue(tbl_exists(database, self.table_name))

        os_file_delete(self.filename)
    def setUp(self):
        self.database_name = 'foobar'
        self.table_name = 'foobar'
        self.column_defn = [('FirstName', 'text'), ('LastName', 'text'),
                            ('Country', 'text'), ('Description', 'text'),
                            ('Age', 'integer')]
        self.columns = [
            'FirstName', 'LastName', 'Country', 'Description', 'Age'
        ]

        self.filename = "b64pyshell.txt"

        append_text_to_file(
            self.filename,
            "database_name:" + b64encode(self.database_name) + "\n")
        append_text_to_file(self.filename,
                            "table_name:" + b64encode(self.table_name) + "\n")
        append_text_to_file(self.filename,
                            "delete_flag:" + b64encode("False") + "\n")
        append_text_to_file(
            self.filename, "column_defns:" + "$$".join([
                b64encode(_name) + "^" + b64encode(_type)
                for _name, _type in self.column_defn
            ]) + "\n")

        DatabaseCreateTable.create_by_file(self.filename)
    def setUp(self):
        self.database_name = 'foobar'
        self.table_name = 'foobar'
        self.columns = ['col1', 'col2', 'col3']
        self.column_defn = [('col1', 'text'), ('col2', 'text'),
                            ('col3', 'integer')]
        self.row = [['x', 'y', 6], ['a', 's', 8], ['f', 'a', 7]]
        self.qrows = _quotestrs(self.row)
        self.filename = "b64pyshell.txt"
        self.encoding = "unicode"

        DatabaseCreateTable.create(self.database_name, self.table_name,
                                   self.column_defn)
 def setUp(self):
     self.database_name = 'foobar'
     self.table_name = 'foobar'
     self.columns = ['col1', 'col2', 'col3']
     self.column_defn = [('col1', 'text'), ('col2', 'text'),
                         ('col3', 'integer')]
     self.row = [['x', 'y', 6], ['a', 's', 8], ['f', 'a', 7]]
     self.qrows = _quotestrs(self.row)
     self.filename = "b64pyshell.txt"
     self.runtime_path = "C:\\Users\\burtnolej"
     DatabaseCreateTable.create(self.database_name,
                                self.table_name,
                                self.column_defn,
                                runtime_path=self.runtime_path)
    def test_create_by_file(self):

        append_text_to_file(self.filename,
                            "database_name:" + self.database_name + "\n")
        append_text_to_file(self.filename,
                            "table_name:" + self.table_name + "\n")
        append_text_to_file(self.filename, "delete_flag:False" + "\n")
        append_text_to_file(
            self.filename, "column_defns:" + "$$".join(
                [_name + "^" + _type
                 for _name, _type in self.column_defn]) + "\n")
        DatabaseCreateTable.create_by_file(self.filename)

        database = Database(self.database_name, True)
        with database:
            self.assertTrue(tbl_exists(database, self.table_name))

        os_file_delete(self.filename)
    def test_create_by_file_encoded(self):
        self.filename = "b64pyshell.txt"
        append_text_to_file(
            self.filename,
            "database_name:" + b64encode(self.database_name) + "\n")
        append_text_to_file(self.filename,
                            "table_name:" + b64encode(self.table_name) + "\n")
        append_text_to_file(self.filename,
                            "delete_flag:" + b64encode("False") + "\n")
        append_text_to_file(
            self.filename, "column_defns:" + "$$".join([
                b64encode(_name) + "^" + b64encode(_type)
                for _name, _type in self.column_defn
            ]) + "\n")
        DatabaseCreateTable.create_by_file(self.filename)

        database = Database(self.database_name, True)
        with database:
            self.assertTrue(tbl_exists(database, self.table_name))

        os_file_delete(self.filename)
    def setUp(self):
        self.database_name = 'foobar'
        self.table_name = 'foobar'
        self.columns = ['col1', 'col2', 'col3']
        self.column_defn = [('col1', 'text'), ('col2', 'text'),
                            ('col3', 'integer')]
        self.row = [['x', 'y', 6]]
        self.qrow = _quotestrs(self.row)
        self.filename = "b64pyshell.txt"
        self.b64row = DatabaseBase._encode_2darray(self.row)

        self.runtime_path = "C:\\Users\\burtnolej"
        append_text_to_file(
            self.filename,
            "database_name:" + b64encode(self.database_name) + "\n")
        append_text_to_file(self.filename,
                            "table_name:" + b64encode(self.table_name) + "\n")
        append_text_to_file(self.filename,
                            "delete_flag:" + b64encode("False") + "\n")
        append_text_to_file(
            self.filename, "columns:" +
            "$$".join([b64encode(field) for field in self.columns]) + "\n")
        append_text_to_file(
            self.filename, "column_defns:" + "$$".join([
                b64encode(_name) + "^" + b64encode(_type)
                for _name, _type in self.column_defn
            ]) + "\n")
        append_text_to_file(
            self.filename, "qry_str:" +
            b64encode("select col1,col2,col3 from " + self.table_name) + "\n")

        put_2darray_in_file(self.filename, self.b64row, suffix="rows:")
        DatabaseCreateTable.create_by_file(self.filename,
                                           runtime_path=self.runtime_path)
        DatabaseInsertRows.insert_by_file(self.filename,
                                          runtime_path=self.runtime_path)
 def test_create(self):
     DatabaseCreateTable.create(self.database_name, self.table_name,
                                self.column_defn)
     database = Database(self.database_name, True)
     with database:
         self.assertTrue(tbl_exists(database, self.table_name))