Closed arossert closed 9 years ago
Hi Daemon22,
Thanks for reporting this. I just pushed a change (based on your suggestion) that should fix it. Please let me know if all is OK.
I also added a test case to check for other names missing from the module. However, I don't have a good cx_Oracle test for that type, could you send me a simplified version of your code using Binary, so I can add to my test suite?
I will also put some effort into integrating the entire SQLAlchemy test suite anyway.
Here is how I'm using SqlAlchemy and Binary:
import uuid from sqlalchemy import Column, create_engine from sqlalchemy.dialects.oracle import RAW from sqlalchemy.exc import SQLAlchemyError from sqlalchemy.ext.declarative import declarative_base from sqlalchemy.orm import sessionmaker
Base = declarative_base() engine = create_engine("oracle://user:pass@host:port/SID", pool_recycle=3600) Session = sessionmaker(bind=engine)
class TestTable(Base): tablename = 'TEST' guid = Column("ID", RAW(16), unique=True)
session = Session() guid = uuid.UUID("05343899-b843-4f10-b460-94410bae1234")
try: test = session.query(TestTable).filter(TestTable.guid == guid).one() print test.guid except SQLAlchemyError, e: print e session.rollback() finally: session.close()
Hi,
I added a test based on an adaptation of your example (see https://github.com/lameiro/cx_oracle_on_ctypes/blob/master/test/integration/sqlalchemy_issues/test_github6-binary-type.py )
This is working now, so I will close this issue, please let me know if you still have problems.
I fixed the problem adding:
import sys def python3_or_better(): v2=str(sys.version_info) vx="major=3" if (v2.find(vx)): return True else: return False
if python3_or_better(): from .types import bytes as BINARY else: from .types import String as BINARY
in sqlalchemy init.py file.
SqlAlchemy crash when searching with 'Binary'.
We fixed this by adding: if python3_or_better(): Binary = bytes else: Binary = str
in the init.py file