Пример #1
0
    def test_memory_sqlite(self):
        ch = ConnectionHelper(ConnectionHelperTest.yaml_file_path)
        connection = ch.get_named_connection("sqlite3")
        connection.cursor().execute("select 'x'")

        connection = ch.get_named_connection("sqlite3_mem")
        conn_info = ch.connections["sqlite3_mem"]
        dialect, dburl = ch.get_components(conn_info["url"])
        self.assertEqual(dialect, "sqlite")
        self.assertEqual(dburl, ":memory:")
        connection.cursor().execute("select 'x'")
Пример #2
0
 def test_sqlite(self):
     ch = ConnectionHelper(ConnectionHelperTest.yaml_file_path)
     connection = ch.get_named_connection("sqlite3")
     self.assertEqual(ConnectionHelper.get_dialect(connection),
                      dialects.DIALECT_SQLITE)
     cursor = connection.cursor()
     self.assertEqual(ConnectionHelper.get_dialect(cursor),
                      dialects.DIALECT_SQLITE)
Пример #3
0
    def test_sqlite_returning(self):
        logger = logging.getLogger(__name__ + ":test_sqlite_returning")
        drop_sql = "drop table if exists a"
        create_sql = "create table a (b serial primary key, c numeric)"
        insert_sql = "insert into a (c) values (%(c)s)"
        returning_text = "returning b"

        ch = ConnectionHelper(ConnectionHelperTest.yaml_file_path)

        connection = ch.get_named_connection("sqlite3_mem")
        cursor = CursorHelper(connection.cursor())
        cursor.execute(drop_sql)
        cursor.execute(create_sql)
        new_id = cursor.execute(insert_sql, {"c": 3}, returning=returning_text)
        self.assertEqual(1, new_id)