How to use the pymssql.Binary function in pymssql

To help you get started, we’ve selected a few pymssql examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github sqlobject / sqlobject / sqlobject / mssql / mssqlconnection.py View on Github external
conn_str += \
                    "Integrated Security=SSPI;Persist Security Info=False"
                self.make_conn_str = lambda keys: conn_str % (
                    keys.host, keys.db)
            else:
                conn_str += "User Id=%s;Password=%s"
                self.make_conn_str = lambda keys: conn_str % (
                    keys.host, keys.db, keys.user, keys.password)

            kw.pop("ncli", None)
            kw.pop("sspi", None)

        elif driver == 'pymssql':
            self.module = sqlmodule
            self.dbconnection = sqlmodule.connect
            sqlmodule.Binary = lambda st: str(st)
            # don't know whether pymssql uses unicode
            self.usingUnicodeStrings = False

            def _make_conn_str(keys):
                keys_dict = {}
                for attr, value in (
                    ('database', keys.db),
                    ('user', keys.user),
                    ('password', keys.password),
                    ('host', keys.host),
                    ('port', keys.port),
                    ('timeout', keys.timeout),
                ):
                    if value:
                        keys_dict[attr] = value
                return keys_dict
github obeattie / sqlalchemy / lib / sqlalchemy / databases / mssql.py View on Github external
def import_dbapi(cls):
        import pymssql as module
        # pymmsql doesn't have a Binary method.  we use string
        # TODO: monkeypatching here is less than ideal
        module.Binary = lambda st: str(st)
        return module
    import_dbapi = classmethod(import_dbapi)
github stoq / stoq / external / sqlobject / mssql / mssqlconnection.py View on Github external
# MSDE does not allow SQL server login
                if kw.get("sspi"):
                    conn_str += "Integrated Security=SSPI;Persist Security Info=False"
                    self.make_conn_str = lambda keys: [conn_str % (keys.host, keys.db)]
                else:
                    conn_str += "User Id=%s;Password=%s"
                    self.make_conn_str = lambda keys: [conn_str % (keys.host, keys.db, keys.user, keys.password)]

                col.popKey(kw, "sspi")
                col.popKey(kw, "ncli")

            except ImportError: # raise the exceptions other than ImportError for adodbapi absence
                import pymssql as sqlmodule
                self.dbconnection = sqlmodule.connect
                sqlmodule.Binary = lambda st: str(st)
                # don't know whether pymssql uses unicode
                self.usingUnicodeStrings = False
                self.make_conn_str = lambda keys:  \
                       ["", keys.user, keys.password, keys.host, keys.db]
        self.autoCommit=int(autoCommit)
        self.host = host
        self.db = db
        self.user = user
        self.password = password
        self.limit_re = re.compile('^\s*(select )(.*)', re.IGNORECASE)
        self.password = password
        self.module = sqlmodule
        DBAPI.__init__(self, **kw)