def create_connect_args(self, url): if url.username or url.password or url.host or url.port: raise exc.ArgumentError( "Invalid SQLite URL: %s\n" "Valid SQLite URL forms are:\n" " sqlite:///:memory: (or, sqlite://)\n" " sqlite:///relative/path/to/file.db\n" " sqlite:////absolute/path/to/file.db" % (url,)) filename = url.database or ':memory:' if filename != ':memory:': filename = os.path.abspath(filename) opts = self._driver_kwargs() opts.update(url.query) util.coerce_kw_type(opts, 'timeout', float) util.coerce_kw_type(opts, 'isolation_level', str) util.coerce_kw_type(opts, 'detect_types', int) util.coerce_kw_type(opts, 'check_same_thread', bool) util.coerce_kw_type(opts, 'cached_statements', int) jdbc_url = "jdbc:sqlite:%s" % filename return [ [ jdbc_url, url.username, url.password, self.jdbc_driver_name ], opts ]
def create_connect_args(self, url): dialect_opts = dict(url.query) for opt in ("use_ansi", "auto_setinputsizes", "auto_convert_lobs", "threaded", "allow_twophase"): if opt in dialect_opts: util.coerce_kw_type(dialect_opts, opt, bool) setattr(self, opt, dialect_opts[opt]) if url.database: # if we have a database, then we have a remote host port = url.port if port: port = int(port) else: port = 1521 dsn = self.dbapi.makedsn(url.host, port, url.database) else: # we have a local tnsname dsn = url.host opts = dict( user=url.username, password=url.password, dsn=dsn, threaded=self.threaded, twophase=self.allow_twophase ) if "mode" in url.query: opts["mode"] = url.query["mode"] if isinstance(opts["mode"], basestring): mode = opts["mode"].upper() if mode == "SYSDBA": opts["mode"] = self.dbapi.SYSDBA elif mode == "SYSOPER": opts["mode"] = self.dbapi.SYSOPER else: util.coerce_kw_type(opts, "mode", int) # Can't set 'handle' or 'pool' via URL query args, use connect_args return ([], opts)
def create_connect_args(self, url): dialect_opts = dict(url.query) for opt in ( "use_ansi", "auto_setinputsizes", "auto_convert_lobs", "threaded", "allow_twophase", ): if opt in dialect_opts: util.coerce_kw_type(dialect_opts, opt, bool) setattr(self, opt, dialect_opts[opt]) database = url.database service_name = dialect_opts.get("service_name", None) if database or service_name: # if we have a database, then we have a remote host port = url.port if port: port = int(port) else: port = 1521 if database and service_name: raise exc.InvalidRequestError( '"service_name" option shouldn\'t ' 'be used with a "database" part of the url') if database: makedsn_kwargs = {"sid": database} if service_name: makedsn_kwargs = {"service_name": service_name} dsn = self.dbapi.makedsn(url.host, port, **makedsn_kwargs) else: # we have a local tnsname dsn = url.host opts = dict(threaded=self.threaded) if dsn is not None: opts["dsn"] = dsn if url.password is not None: opts["password"] = url.password if url.username is not None: opts["user"] = url.username if "mode" in url.query: opts["mode"] = url.query["mode"] if isinstance(opts["mode"], util.string_types): mode = opts["mode"].upper() if mode == "SYSDBA": opts["mode"] = self.dbapi.SYSDBA elif mode == "SYSOPER": opts["mode"] = self.dbapi.SYSOPER else: util.coerce_kw_type(opts, "mode", int) return ([], opts)
def create_connect_args(self, url): dialect_opts = dict(url.query) for opt in ('use_ansi', 'auto_setinputsizes', 'auto_convert_lobs', 'threaded', 'allow_twophase'): if opt in dialect_opts: util.coerce_kw_type(dialect_opts, opt, bool) setattr(self, opt, dialect_opts[opt]) database = url.database service_name = dialect_opts.get('service_name', None) if database.endswith(':timesten_direct') or database.endswith( ':timesten_client'): dsn = url.host + '/' + database self.is_timesten = True elif database or service_name: # if we have a database, then we have a remote host port = url.port if port: port = int(port) else: port = 1521 if database and service_name: raise exc.InvalidRequestError( '"service_name" option shouldn\'t ' 'be used with a "database" part of the url') if database: makedsn_kwargs = {'sid': database} if service_name: makedsn_kwargs = {'service_name': service_name} dsn = self.dbapi.makedsn(url.host, port, **makedsn_kwargs) else: # we have a local tnsname dsn = url.host opts = dict(threaded=self.threaded, ) if dsn is not None: opts['dsn'] = dsn if url.password is not None: opts['password'] = url.password if url.username is not None: opts['user'] = url.username if 'mode' in url.query: opts['mode'] = url.query['mode'] if isinstance(opts['mode'], util.string_types): mode = opts['mode'].upper() if mode == 'SYSDBA': opts['mode'] = self.dbapi.SYSDBA elif mode == 'SYSOPER': opts['mode'] = self.dbapi.SYSOPER else: util.coerce_kw_type(opts, 'mode', int) return ([], opts)
def create_connect_args(self, url): opts = url.translate_connect_args(username="******") if opts.get("port"): opts["host"] = "%s/%s" % (opts["host"], opts["port"]) del opts["port"] opts.update(url.query) util.coerce_kw_type(opts, "type_conv", int) return ([], opts)
def create_connect_args(self, url): dialect_opts = dict(url.query) for opt in ('use_ansi', 'auto_setinputsizes', 'auto_convert_lobs', 'threaded', 'allow_twophase'): if opt in dialect_opts: util.coerce_kw_type(dialect_opts, opt, bool) setattr(self, opt, dialect_opts[opt]) database = url.database service_name = dialect_opts.get('service_name', None) if database or service_name: # if we have a database, then we have a remote host port = url.port if port: port = int(port) else: port = 1521 if database and service_name: raise exc.InvalidRequestError( '"service_name" option shouldn\'t ' 'be used with a "database" part of the url') if database: makedsn_kwargs = {'sid': database} if service_name: makedsn_kwargs = {'service_name': service_name} dsn = self.dbapi.makedsn(url.host, port, **makedsn_kwargs) else: # we have a local tnsname dsn = url.host opts = dict( threaded=self.threaded, ) if dsn is not None: opts['dsn'] = dsn if url.password is not None: opts['password'] = url.password if url.username is not None: opts['user'] = url.username if 'mode' in url.query: opts['mode'] = url.query['mode'] if isinstance(opts['mode'], util.string_types): mode = opts['mode'].upper() if mode == 'SYSDBA': opts['mode'] = self.dbapi.SYSDBA elif mode == 'SYSOPER': opts['mode'] = self.dbapi.SYSOPER else: util.coerce_kw_type(opts, 'mode', int) return ([], opts)
def create_connect_args(self, url): filename = url.database or ":memory:" opts = url.query.copy() util.coerce_kw_type(opts, "timeout", float) util.coerce_kw_type(opts, "isolation_level", str) util.coerce_kw_type(opts, "detect_types", int) util.coerce_kw_type(opts, "check_same_thread", bool) util.coerce_kw_type(opts, "cached_statements", int) return ([filename], opts)
def create_connect_args(self, url): filename = url.database or ':memory:' opts = url.query.copy() util.coerce_kw_type(opts, 'timeout', float) util.coerce_kw_type(opts, 'isolation_level', str) util.coerce_kw_type(opts, 'detect_types', int) util.coerce_kw_type(opts, 'check_same_thread', bool) util.coerce_kw_type(opts, 'cached_statements', int) return ([filename], opts)
def create_connect_args(self, url): dialect_opts = dict(url.query) for opt in ('use_ansi', 'auto_setinputsizes', 'auto_convert_lobs', 'threaded', 'allow_twophase'): if opt in dialect_opts: util.coerce_kw_type(dialect_opts, opt, bool) setattr(self, opt, dialect_opts[opt]) if url.database: # if we have a database, then we have a remote host port = url.port if port: port = int(port) else: port = 1521 dsn = self.dbapi.makedsn(url.host, port, url.database) else: # we have a local tnsname dsn = url.host opts = dict( user=url.username, password=url.password, dsn=dsn, threaded=self.threaded, twophase=self.allow_twophase, ) # Py2K if self._cx_oracle_with_unicode: for k, v in opts.items(): if isinstance(v, str): opts[k] = unicode(v) else: for k, v in opts.items(): if isinstance(v, unicode): opts[k] = str(v) # end Py2K if 'mode' in url.query: opts['mode'] = url.query['mode'] if isinstance(opts['mode'], basestring): mode = opts['mode'].upper() if mode == 'SYSDBA': opts['mode'] = self.dbapi.SYSDBA elif mode == 'SYSOPER': opts['mode'] = self.dbapi.SYSOPER else: util.coerce_kw_type(opts, 'mode', int) return ([], opts)
def _coerce_config(configuration, prefix): """Convert configuration values to expected types.""" options = dict((key[len(prefix) :], configuration[key]) for key in configuration if key.startswith(prefix)) for option, type_ in ( ("convert_unicode", bool), ("pool_timeout", int), ("echo", bool), ("echo_pool", bool), ("pool_recycle", int), ("pool_size", int), ("max_overflow", int), ("pool_threadlocal", bool), ): util.coerce_kw_type(options, option, type_) return options
def _coerce_config(configuration, prefix): """Convert configuration values to expected types.""" options = dict([(key[len(prefix):], configuration[key]) for key in configuration if key.startswith(prefix)]) for option, type_ in ( ('convert_unicode', bool), ('pool_timeout', int), ('echo', bool), ('echo_pool', bool), ('pool_recycle', int), ('pool_size', int), ('max_overflow', int), ('pool_threadlocal', bool), ): util.coerce_kw_type(options, option, type_) return options
def create_connect_args(self, url): if url.username or url.password or url.host or url.port: raise exc.ArgumentError( "Invalid SQLite URL: %s\n" "Valid SQLite URL forms are:\n" " sqlite:///:memory: (or, sqlite://)\n" " sqlite:///relative/path/to/file.db\n" " sqlite:////absolute/path/to/file.db" % (url,)) filename = url.database or ':memory:' opts = url.query.copy() util.coerce_kw_type(opts, 'timeout', float) util.coerce_kw_type(opts, 'isolation_level', str) util.coerce_kw_type(opts, 'detect_types', int) util.coerce_kw_type(opts, 'check_same_thread', bool) util.coerce_kw_type(opts, 'cached_statements', int) return ([filename], opts)
def create_connect_args(self, url): if url.username or url.password or url.host or url.port: raise exc.ArgumentError("Invalid SQLite URL: %s\n" "Valid SQLite URL forms are:\n" " sqlite:///:memory: (or, sqlite://)\n" " sqlite:///relative/path/to/file.db\n" " sqlite:////absolute/path/to/file.db" % (url, )) filename = url.database or ':memory:' opts = url.query.copy() util.coerce_kw_type(opts, 'timeout', float) util.coerce_kw_type(opts, 'isolation_level', str) util.coerce_kw_type(opts, 'detect_types', int) util.coerce_kw_type(opts, 'check_same_thread', bool) util.coerce_kw_type(opts, 'cached_statements', int) return ([filename], opts)
def create_connect_args(self, url): dialect_opts = dict(url.query) for opt in ("use_ansi", "auto_setinputsizes", "auto_convert_lobs", "threaded", "allow_twophase"): if opt in dialect_opts: util.coerce_kw_type(dialect_opts, opt, bool) setattr(self, opt, dialect_opts[opt]) if url.database: # if we have a database, then we have a remote host port = url.port if port: port = int(port) else: port = 1521 dsn = self.dbapi.makedsn(url.host, port, url.database) else: # we have a local tnsname dsn = url.host opts = dict( user=url.username, password=url.password, dsn=dsn, threaded=self.threaded, twophase=self.allow_twophase ) if util.py2k: if self._cx_oracle_with_unicode: for k, v in opts.items(): if isinstance(v, str): opts[k] = unicode(v) else: for k, v in opts.items(): if isinstance(v, unicode): opts[k] = str(v) if "mode" in url.query: opts["mode"] = url.query["mode"] if isinstance(opts["mode"], util.string_types): mode = opts["mode"].upper() if mode == "SYSDBA": opts["mode"] = self.dbapi.SYSDBA elif mode == "SYSOPER": opts["mode"] = self.dbapi.SYSOPER else: util.coerce_kw_type(opts, "mode", int) return ([], opts)
def _create_jdbc_url(self, url): """Create a JDBC url from a :class:`~sqlalchemy.engine.url.URL`""" opts = url.translate_connect_args(database='db', username='******',password='******') opts.update(url.query) util.coerce_kw_type(opts, 'mode', str) print opts['mode'] print url.database jdbc_url = 'jdbc:%s:%s://localhost/%s;' % (self.jdbc_db_name, opts['mode'], url.database) jdbc_url = '' print jdbc_url #MVCC=TRUE, can't change when db opened return jdbc_url
def create_connect_args(self, url): opts = url.translate_connect_args(username='******') opts.update(url.query) util.coerce_kw_type(opts, 'buffered', bool) util.coerce_kw_type(opts, 'raise_on_warnings', bool) opts['buffered'] = True opts['raise_on_warnings'] = True # FOUND_ROWS must be set in ClientFlag to enable # supports_sane_rowcount. if self.dbapi is not None: try: from mysql.connector.constants import ClientFlag client_flags = opts.get('client_flags', ClientFlag.get_default()) client_flags |= ClientFlag.FOUND_ROWS opts['client_flags'] = client_flags except: pass return [[], opts]
def create_connect_args(self, url): opts = url.translate_connect_args(username='******') if opts.get('port'): opts['host'] = "%s/%s" % (opts['host'], opts['port']) del opts['port'] opts.update(url.query) util.coerce_kw_type(opts, 'type_conv', int) type_conv = opts.pop('type_conv', self.type_conv) concurrency_level = opts.pop('concurrency_level', self.concurrency_level) if self.dbapi is not None: initialized = getattr(self.dbapi, 'initialized', None) if initialized is None: # CVS rev 1.96 changed the name of the attribute: # http://kinterbasdb.cvs.sourceforge.net/viewvc/kinterbasdb/Kinterbasdb-3.0/__init__.py?r1=1.95&r2=1.96 initialized = getattr(self.dbapi, '_initialized', False) if not initialized: self.dbapi.init(type_conv=type_conv, concurrency_level=concurrency_level) return ([], opts)
def create_connect_args(self, url): if url.database: # if we have a database, then we have a remote host port = url.port if port: port = int(port) else: port = 1521 dsn = self.dbapi.makedsn(url.host,port,url.database) else: # we have a local tnsname dsn = url.host opts = dict( user=url.username, password=url.password, dsn = dsn, threaded = self.threaded ) opts.update(url.query) util.coerce_kw_type(opts, 'use_ansi', bool) return ([], opts)
def create_connect_args(self, url): dialect_opts = dict(url.query) for opt in ('use_ansi', 'auto_setinputsizes', 'auto_convert_lobs', 'threaded', 'allow_twophase'): if opt in dialect_opts: util.coerce_kw_type(dialect_opts, opt, bool) setattr(self, opt, dialect_opts[opt]) if url.database: # if we have a database, then we have a remote host port = url.port if port: port = int(port) else: port = 1521 dsn = self.dbapi.makedsn(url.host, port, url.database) else: # we have a local tnsname dsn = url.host opts = dict( user=url.username, password=url.password, dsn=dsn, threaded=self.threaded, twophase=self.allow_twophase, ) if 'mode' in url.query: opts['mode'] = url.query['mode'] if isinstance(opts['mode'], basestring): mode = opts['mode'].upper() if mode == 'SYSDBA': opts['mode'] = self.dbapi.SYSDBA elif mode == 'SYSOPER': opts['mode'] = self.dbapi.SYSOPER else: util.coerce_kw_type(opts, 'mode', int) # Can't set 'handle' or 'pool' via URL query args, use connect_args return ([], opts)
def _create_jdbc_url(self, url): """Create a JDBC url from a :class:`~sqlalchemy.engine.url.URL`""" opts = url.translate_connect_args(database='db', username='******', password='******') opts.update(url.query) util.coerce_kw_type(opts, 'mode', str) print opts['mode'] print url.database jdbc_url = 'jdbc:%s:%s://localhost/%s;' % (self.jdbc_db_name, opts['mode'], url.database) jdbc_url = '' print jdbc_url #MVCC=TRUE, can't change when db opened return jdbc_url
def create_connect_args(self, url): opts = url.translate_connect_args(username="******") if opts.get("port"): opts["host"] = "%s/%s" % (opts["host"], opts["port"]) del opts["port"] opts.update(url.query) util.coerce_kw_type(opts, "type_conv", int) type_conv = opts.pop("type_conv", self.type_conv) concurrency_level = opts.pop("concurrency_level", self.concurrency_level) if self.dbapi is not None: initialized = getattr(self.dbapi, "initialized", None) if initialized is None: # CVS rev 1.96 changed the name of the attribute: # http://kinterbasdb.cvs.sourceforge.net/viewvc/kinterbasdb/ # Kinterbasdb-3.0/__init__.py?r1=1.95&r2=1.96 initialized = getattr(self.dbapi, "_initialized", False) if not initialized: self.dbapi.init(type_conv=type_conv, concurrency_level=concurrency_level) return ([], opts)
def create_connect_args(self, url): opts = url.query.copy() util.coerce_kw_type(opts, 'connect_timeout', float) util.coerce_kw_type(opts, 'detect_types', int) util.coerce_kw_type(opts, 'max_redirects', int) opts['port'] = url.port opts['host'] = url.host if url.username: opts['user'] = url.username if url.password: opts['password'] = url.password return ([], opts)
def create_connect_args(self, url): if url.username or url.password: raise exc.ArgumentError( "Invalid RQLite URL: %s\n" "Valid RQLite URL forms are:\n" " rqlite+pyrqlite://host:port/[?params]" % (url,)) opts = url.query.copy() util.coerce_kw_type(opts, 'connect_timeout', float) util.coerce_kw_type(opts, 'detect_types', int) util.coerce_kw_type(opts, 'max_redirects', int) opts['port'] = url.port opts['host'] = url.host return ([], opts)
def create_connect_args(self, url): opts = url.translate_connect_args(database="db", username="******", password="******") opts.update(url.query) util.coerce_kw_type(opts, "compress", bool) util.coerce_kw_type(opts, "connect_timeout", int) util.coerce_kw_type(opts, "client_flag", int) util.coerce_kw_type(opts, "local_infile", int) # Note: using either of the below will cause all strings to be returned # as Unicode, both in raw SQL operations and with column types like # String and MSString. util.coerce_kw_type(opts, "use_unicode", bool) util.coerce_kw_type(opts, "charset", str) # Rich values 'cursorclass' and 'conv' are not supported via # query string. ssl = {} for key in ["ssl_ca", "ssl_key", "ssl_cert", "ssl_capath", "ssl_cipher"]: if key in opts: ssl[key[4:]] = opts[key] util.coerce_kw_type(ssl, key[4:], str) del opts[key] if ssl: opts["ssl"] = ssl # FOUND_ROWS must be set in CLIENT_FLAGS to enable # supports_sane_rowcount. client_flag = opts.get("client_flag", 0) if self.dbapi is not None: try: CLIENT_FLAGS = __import__(self.dbapi.__name__ + ".constants.CLIENT").constants.CLIENT client_flag |= CLIENT_FLAGS.FOUND_ROWS except (AttributeError, ImportError): self.supports_sane_rowcount = False opts["client_flag"] = client_flag return [[], opts]
def create_connect_args(self, url): opts = dict(url.query) for opt in ('use_ansi', 'auto_convert_lobs'): if opt in opts: util.warn_deprecated( "cx_oracle dialect option %r should only be passed to " "create_engine directly, not within the URL string" % opt) util.coerce_kw_type(opts, opt, bool) setattr(self, opt, opts.pop(opt)) database = url.database service_name = opts.pop('service_name', None) if database or service_name: # if we have a database, then we have a remote host port = url.port if port: port = int(port) else: port = 1521 if database and service_name: raise exc.InvalidRequestError( '"service_name" option shouldn\'t ' 'be used with a "database" part of the url') if database: makedsn_kwargs = {'sid': database} if service_name: makedsn_kwargs = {'service_name': service_name} dsn = self.dbapi.makedsn(url.host, port, **makedsn_kwargs) else: # we have a local tnsname dsn = url.host if dsn is not None: opts['dsn'] = dsn if url.password is not None: opts['password'] = url.password if url.username is not None: opts['user'] = url.username if self._cx_oracle_threaded is not None: opts.setdefault("threaded", self._cx_oracle_threaded) def convert_cx_oracle_constant(value): if isinstance(value, util.string_types): try: int_val = int(value) except ValueError: value = value.upper() return getattr(self.dbapi, value) else: return int_val else: return value util.coerce_kw_type(opts, 'mode', convert_cx_oracle_constant) util.coerce_kw_type(opts, 'threaded', bool) util.coerce_kw_type(opts, 'events', bool) util.coerce_kw_type(opts, 'purity', convert_cx_oracle_constant) return ([], opts)
def create_connect_args(self, url): dialect_opts = dict(url.query) for opt in ('use_ansi', 'auto_setinputsizes', 'auto_convert_lobs', 'threaded', 'allow_twophase'): if opt in dialect_opts: util.coerce_kw_type(dialect_opts, opt, bool) setattr(self, opt, dialect_opts[opt]) database = url.database service_name = dialect_opts.get('service_name', None) if database or service_name: # if we have a database, then we have a remote host port = url.port if port: port = int(port) else: port = 1521 if database and service_name: raise exc.InvalidRequestError( '"service_name" option shouldn\'t ' 'be used with a "database" part of the url') if database: makedsn_kwargs = {'sid': database} if service_name: makedsn_kwargs = {'service_name': service_name} dsn = self.dbapi.makedsn(url.host, port, **makedsn_kwargs) else: # we have a local tnsname dsn = url.host opts = dict( user=url.username, password=url.password, dsn=dsn, threaded=self.threaded, twophase=self.allow_twophase, ) if util.py2k: if self._cx_oracle_with_unicode: for k, v in opts.items(): if isinstance(v, str): opts[k] = unicode(v) else: for k, v in opts.items(): if isinstance(v, unicode): opts[k] = str(v) if 'mode' in url.query: opts['mode'] = url.query['mode'] if isinstance(opts['mode'], util.string_types): mode = opts['mode'].upper() if mode == 'SYSDBA': opts['mode'] = self.dbapi.SYSDBA elif mode == 'SYSOPER': opts['mode'] = self.dbapi.SYSOPER else: util.coerce_kw_type(opts, 'mode', int) return ([], opts)
def create_connect_args(self, url): opts = url.translate_connect_args(['host', 'db', 'user', 'passwd', 'port']) opts.update(url.query) util.coerce_kw_type(opts, 'compress', bool) util.coerce_kw_type(opts, 'connect_timeout', int) util.coerce_kw_type(opts, 'client_flag', int) util.coerce_kw_type(opts, 'local_infile', int) # note: these two could break SA Unicode type util.coerce_kw_type(opts, 'use_unicode', bool) util.coerce_kw_type(opts, 'charset', str) # TODO: cursorclass and conv: support via query string or punt? # ssl ssl = {} for key in ['ssl_ca', 'ssl_key', 'ssl_cert', 'ssl_capath', 'ssl_cipher']: if key in opts: ssl[key[4:]] = opts[key] util.coerce_kw_type(ssl, key[4:], str) del opts[key] if len(ssl): opts['ssl'] = ssl # FOUND_ROWS must be set in CLIENT_FLAGS for to enable # supports_sane_rowcount. client_flag = opts.get('client_flag', 0) if self.dbapi is not None: try: import MySQLdb.constants.CLIENT as CLIENT_FLAGS client_flag |= CLIENT_FLAGS.FOUND_ROWS except: pass opts['client_flag'] = client_flag return [[], opts]
def create_connect_args(self, url): opts = url.translate_connect_args(database='db', username='******', password='******') opts.update(url.query) util.coerce_kw_type(opts, 'compress', bool) util.coerce_kw_type(opts, 'connect_timeout', int) util.coerce_kw_type(opts, 'client_flag', int) util.coerce_kw_type(opts, 'local_infile', int) # Note: using either of the below will cause all strings to be returned # as Unicode, both in raw SQL operations and with column types like # String and MSString. util.coerce_kw_type(opts, 'use_unicode', bool) util.coerce_kw_type(opts, 'charset', str) # Rich values 'cursorclass' and 'conv' are not supported via # query string. ssl = {} for key in ['ssl_ca', 'ssl_key', 'ssl_cert', 'ssl_capath', 'ssl_cipher']: if key in opts: ssl[key[4:]] = opts[key] util.coerce_kw_type(ssl, key[4:], str) del opts[key] if ssl: opts['ssl'] = ssl # FOUND_ROWS must be set in CLIENT_FLAGS to enable # supports_sane_rowcount. client_flag = opts.get('client_flag', 0) if self.dbapi is not None: try: from MySQLdb.constants import CLIENT as CLIENT_FLAGS client_flag |= CLIENT_FLAGS.FOUND_ROWS except: pass opts['client_flag'] = client_flag return [[], opts]
def create_connect_args(self, url): opts = url.translate_connect_args(database='db', username='******', password='******') opts.update(url.query) util.coerce_kw_type(opts, 'port', int) util.coerce_kw_type(opts, 'compress', bool) util.coerce_kw_type(opts, 'autoping', bool) util.coerce_kw_type(opts, 'default_charset', bool) if opts.pop('default_charset', False): opts['charset'] = None else: util.coerce_kw_type(opts, 'charset', str) opts['use_unicode'] = opts.get('use_unicode', True) util.coerce_kw_type(opts, 'use_unicode', bool) # FOUND_ROWS must be set in CLIENT_FLAGS to enable # supports_sane_rowcount. opts.setdefault('found_rows', True) return [[], opts]
def create_connect_args(self, url): opts = url.translate_connect_args(database='db', username='******', password='******') opts.update(url.query) util.coerce_kw_type(opts, 'port', int) util.coerce_kw_type(opts, 'compress', bool) util.coerce_kw_type(opts, 'autoping', bool) util.coerce_kw_type(opts, 'default_charset', bool) if opts.pop('default_charset', False): opts['charset'] = None else: util.coerce_kw_type(opts, 'charset', str) opts['use_unicode'] = opts.get('use_unicode', True) util.coerce_kw_type(opts, 'use_unicode', bool) # FOUND_ROWS must be set in CLIENT_FLAGS to enable # supports_sane_rowcount. opts.setdefault('found_rows', True) ssl = {} for key in ['ssl_ca', 'ssl_key', 'ssl_cert', 'ssl_capath', 'ssl_cipher']: if key in opts: ssl[key[4:]] = opts[key] util.coerce_kw_type(ssl, key[4:], str) del opts[key] if ssl: opts['ssl'] = ssl return [[], opts]
def create_connect_args(self, url): opts = url.translate_connect_args(database='db', username='******', password='******') opts.update(url.query) util.coerce_kw_type(opts, 'compress', bool) util.coerce_kw_type(opts, 'connect_timeout', int) util.coerce_kw_type(opts, 'client_flag', int) util.coerce_kw_type(opts, 'local_infile', int) # Note: using either of the below will cause all strings to be returned # as Unicode, both in raw SQL operations and with column types like # String and MSString. util.coerce_kw_type(opts, 'use_unicode', bool) util.coerce_kw_type(opts, 'charset', str) # Rich values 'cursorclass' and 'conv' are not supported via # query string. ssl = {} for key in ['ssl_ca', 'ssl_key', 'ssl_cert', 'ssl_capath', 'ssl_cipher']: if key in opts: ssl[key[4:]] = opts[key] util.coerce_kw_type(ssl, key[4:], str) del opts[key] if ssl: opts['ssl'] = ssl # FOUND_ROWS must be set in CLIENT_FLAGS to enable # supports_sane_rowcount. client_flag = opts.get('client_flag', 0) if self.dbapi is not None: try: CLIENT_FLAGS = __import__( self.dbapi.__name__ + '.constants.CLIENT' ).constants.CLIENT client_flag |= CLIENT_FLAGS.FOUND_ROWS except (AttributeError, ImportError): pass opts['client_flag'] = client_flag return [[], opts]
def create_connect_args(self, url): opts = url.translate_connect_args(database='db', username='******', password='******') opts.update(url.query) util.coerce_kw_type(opts, 'port', int) util.coerce_kw_type(opts, 'compress', bool) util.coerce_kw_type(opts, 'autoping', bool) util.coerce_kw_type(opts, 'default_charset', bool) if opts.pop('default_charset', False): opts['charset'] = None else: util.coerce_kw_type(opts, 'charset', str) opts['use_unicode'] = opts.get('use_unicode', True) util.coerce_kw_type(opts, 'use_unicode', bool)