Exemple #1
0
 def test_raw_roundtrip(self):
     metadata = self.metadata
     raw_table = Table(
         "raw",
         metadata,
         Column("id", Integer, primary_key=True),
         Column("data", oracle.RAW(35)),
     )
     metadata.create_all()
     testing.db.execute(raw_table.insert(), id=1, data=b("ABCDEF"))
     eq_(testing.db.execute(raw_table.select()).first(), (1, b("ABCDEF")))
Exemple #2
0
 def test_nonunicode_default(self):
     default = b("foo")
     assert_raises_message(
         sa.exc.SAWarning,
         "Unicode column 'foobar' has non-unicode "
         "default value b?'foo' specified.",
         Column,
         "foobar",
         Unicode(32),
         default=default,
     )
    def test_unicode_warnings_dialectlevel(self):

        unicodedata = self.data

        with testing.expect_deprecated(
                "The create_engine.convert_unicode parameter and "
                "corresponding dialect-level"):
            dialect = default.DefaultDialect(convert_unicode=True)
        dialect.supports_unicode_binds = False

        s = String()
        uni = s.dialect_impl(dialect).bind_processor(dialect)

        uni(util.b("x"))
        assert isinstance(uni(unicodedata), util.binary_type)

        eq_(uni(unicodedata), unicodedata.encode("utf-8"))
Exemple #4
0
    def insert_data(cls, connection):
        cls.data = data = [
            dict(
                id=i,
                data="this is text %d" % i,
                bindata=b("this is binary %d" % i),
            )
            for i in range(1, 20)
        ]

        connection.execute(cls.tables.z_test.insert(), data)

        binary_table = cls.tables.binary_table
        fname = os.path.join(
            os.path.dirname(__file__), "..", "..", "binary_data_one.dat"
        )
        with open(fname, "rb") as file_:
            cls.stream = stream = file_.read(12000)

        for i in range(1, 11):
            connection.execute(binary_table.insert(), id=i, data=stream)
Exemple #5
0
 def test_lobs_with_convert_raw(self):
     row = testing.db.execute("select data, bindata from z_test").first()
     eq_(row["data"], "this is text 1")
     eq_(row["bindata"], b("this is binary 1"))
Exemple #6
0
 def test_lobs_with_convert(self):
     t = self.tables.z_test
     row = testing.db.execute(t.select().where(t.c.id == 1)).first()
     eq_(row["data"], "this is text 1")
     eq_(row["bindata"], b("this is binary 1"))
Exemple #7
0
 def test_lobs_without_convert(self):
     engine = testing_engine(options=dict(auto_convert_lobs=False))
     t = self.tables.z_test
     row = engine.execute(t.select().where(t.c.id == 1)).first()
     eq_(row["data"].read(), "this is text 1")
     eq_(row["bindata"].read(), b("this is binary 1"))
 def test_character_binary(self):
     self._test_round_trip(mssql.MSVarBinary(800), b("some normal data"))