Пример #1
0
  def create_connect_args(self, url):
    """ Inputs:  sqlalchemy.engine.url object (attributes parsed from a RFC-1738-style string using
                 module-level make_url() function - driver://username:password@host:port/database or
                 driver:///?<attrib_1_name>=<attrib_1_value>;<attrib_2_name>=<attrib_2_value>)
        Returns: tuple consisting of a *args/**kwargs suitable to send directly to the dbapi connect function.
                 DBAPI.connect(dsn, user='', password='', host='', database='', conn_options=None)
                 DSN: 'DRIVER={IBM DB2 ODBC DRIVER};DATABASE=db_name;HOSTNAME=host_addr;
                       PORT=50000;PROTOCOL=TCPIP;UID=user_id;PWD=secret'
    """
    conn_args = url.translate_connect_args()

    # DSN support through CLI configuration (../cfg/db2cli.ini), while 2 connection
    # attributes are mandatory: database alias and UID (in support to current schema),
    # all the other connection attributes (protocol, hostname, servicename) are provided
    # through db2cli.ini database catalog entry.
    # Example 1: ibm_db_sa:///<database_alias>?UID=db2inst1 or 
    # Example 2: ibm_db_sa:///?DSN=<database_alias>;UID=db2inst1
    if str(url).find('///') != -1:
      dsn, uid, pwd = '', '', ''
      if 'database' in conn_args and conn_args['database'] is not None:
        dsn = conn_args['database']
      else:
        if 'DSN' in url.query and url.query['DSN'] is not None:
          dsn = url.query['DSN']
      if 'UID' in url.query and url.query['UID'] is not None:
        uid = url.query['UID']
      if 'PWD' in url.query and url.query['PWD'] is not None:
        pwd = url.query['PWD']
      return ((dsn, uid, pwd,'',''), {})
    else:
      # Full URL string support for connection to remote data servers
      return ( () , { 'dsn':conn_args['database'] , 'uid':conn_args['username'] , 'pwd':conn_args['password'] } )
Пример #2
0
 def create_connect_args(self, url):
     opts = url.translate_connect_args(username='******', password='******',
                                       database='dbn' )
     if 'host' in opts.keys() and 'port' in opts.keys():
         opts['host'] += ':%s' % opts['port']
         del opts['port']
     #
     return ([], opts)
Пример #3
0
 def create_connect_args(self, url):
     opts = url.translate_connect_args(username='******',
                                       password='******',
                                       database='dbn')
     if 'host' in opts.keys() and 'port' in opts.keys():
         opts['host'] += ':%s' % opts['port']
         del opts['port']
     #
     return ([], opts)
Пример #4
0
    def create_connect_args(self, url):

        # get extra options
        dialect_opts = dict(url.query)

        opts = url.translate_connect_args(username='******', password='******',
                                          database='dbn' )
        keys = list(opts.keys())
        if 'host' in keys and 'port' in keys:
            opts['host'] += ':%s' % opts['port']
            del opts['port']
        #
        opts.update(dialect_opts)
        return ([], opts)
Пример #5
0
    def create_connect_args(self, url):

        # get extra options
        dialect_opts = dict(url.query)

        opts = url.translate_connect_args(username='******',
                                          password='******',
                                          database='dbn')
        keys = list(opts.keys())
        if 'host' in keys and 'port' in keys:
            opts['host'] += ':%s' % opts['port']
            del opts['port']
        #
        opts.update(dialect_opts)
        return ([], opts)
Пример #6
0
 def create_connect_args(self, url):
     """ Inputs:  sqlalchemy.engine.url object (attributes parsed from a RFC-1738-style string using
              module-level make_url() function - driver://username:password@host:port/database or
              driver:///?<attrib_1_name>=<attrib_1_value>;<attrib_2_name>=<attrib_2_value>)
     Returns: tuple consisting of a *args/**kwargs suitable to send directly to the dbapi connect function.
              DBAPI.connect(dsn, user='', password='', host='', database='', conn_options=None)
              DSN: 'DRIVER={IBM DB2 ODBC DRIVER};DATABASE=db_name;HOSTNAME=host_addr;
                    PORT=50000;PROTOCOL=TCPIP;UID=user_id;PWD=secret'
 """
     conn_args = url.translate_connect_args()
     adodb_param = ['Provider=IBMDA400.DataSource.1']
     adodb_param.append('Persist Security Info=True')
     adodb_param.append('User ID=%s' % conn_args['username'])
     adodb_param.append('Password=%s' % conn_args['password'])
     adodb_param.append('Password=%s' % conn_args['password'])
     adodb_param.append('Data Source=%s' % conn_args['host'])
     adodb_param.append('Initial Catalog=%s' % conn_args['database'])
     param = ';'.join(adodb_param)
     dsn += ';'
     dialect.logger.debug("\n  ***  DB2_400Dialect::create_connect_args: " +
                          str(dsn))
     return [[dsn], {}]