예제 #1
0
class test_adsdb(dbapi20.DatabaseAPI20Test):

    # Delete the test.add from a previous run if it is leftover
    if os.access('c:\\test.add', os.F_OK):
        os.remove('c:\\test.add')
        os.remove('c:\\test.ai')
        os.remove('c:\\test.am')

    # Create a database for testing
    conn = adsdb.connect(DataSource='c:\\', ServerType='local or remote')
    cur = conn.cursor()
    cur.execute("CREATE DATABASE [test.add]")
    conn.close()

    # These variables setup the python unit tests to use our driver (adsdb) and our connection string
    driver = adsdb
    connect_args = ()
    connect_kw_args = dict()
    connect_kw_args = dict(DataSource='C:\\test.add',
                           ServerType='local or remote',
                           UserID='ADSSYS')

    def test_setoutputsize(self):
        pass

    def test_setoutputsize_basic(self):
        pass
예제 #2
0
def get_connection(data_source=DATA_SOURCE, login=LOGIN):
    if data_source == u"":
        data_source = DATA_SOURCE.encode("utf-8")
    if login == u"":
        login = LOGIN.encode("utf-8")
    conn = None
    try:
        conn = adsdb.connect(DataSource=data_source, UserID=login, ServerType='local or remote')
    except Exception as ex:
        print ex.args
        add_to_log(ex.args)
    return conn
예제 #3
0
def get_connection(data_source=DATA_SOURCE, login=LOGIN):
    if isinstance(data_source, unicode):
        data_source = data_source.encode("utf-8")

    if isinstance(login, unicode):
        login = login.encode("utf-8")

    if data_source == "":
        data_source = DATA_SOURCE.encode("utf-8")
    if login == "":
        login = LOGIN.encode("utf-8")

    conn = None
    try:
        conn = adsdb.connect(DataSource=data_source,
                             UserID=login,
                             ServerType='local or remote')
    except Exception as ex:
        print ex.args
    return conn
예제 #4
0
    def _cursor(self):
        if not self._valid_connection():
            kwargs = {}
            links = {}
            settings_dict = self.settings_dict
            if settings_dict['USER']:
                kwargs['UserID'] = settings_dict['USER']
            if settings_dict['NAME']:
                kwargs['DataSource'] = settings_dict['NAME']
            if settings_dict['PASSWORD']:
                kwargs['PASSWORD'] = settings_dict['PASSWORD']
            kwargs.update(settings_dict['OPTIONS'])
            # Save the table type
            self.ops.ads_table_type = settings_dict['OPTIONS']['TableType']
            if self.ops.ads_table_type == None:
                # default to ADT if the table type wasn't specified
                self.ops.ads_table_type = 'ADT'
            self.connection = Database.connect(**kwargs)
            connection_created.send(sender=self.__class__)
        cursor = CursorWrapper(self.connection.cursor())

        return cursor
예제 #5
0
파일: test.py 프로젝트: mherrmann/adsdb
# -*- coding: utf-8 -*-
#######################################################################
# Copyright 1994-2011 iAnywhere Solutions, Inc.  All rights reserved.
# This sample code is provided AS IS, without warranty or liability
# of any kind.
# 
# You may use, reproduce, modify and distribute this sample code
# without limitation, on the condition that you retain the foregoing
# copyright notice and disclaimer as to the original iAnywhere code.
# 
#######################################################################

import adsdb

# Adjust the connection path (C:\) and server type as necessary
conn = adsdb.connect(DataSource='c:\\', ServerType='local or remote')
cur = conn.cursor()

cur.execute(u"select 'Hellö Wörld' from system.iota")
assert cur.fetchone()[0] == u'Hellö Wörld'

conn.close()
print('adsdb successfully installed.')

예제 #6
0
파일: test.py 프로젝트: ChrisCPoirier/adsdb
#######################################################################
# Copyright 1994-2011 iAnywhere Solutions, Inc.  All rights reserved.
# This sample code is provided AS IS, without warranty or liability
# of any kind.
# 
# You may use, reproduce, modify and distribute this sample code
# without limitation, on the condition that you retain the foregoing
# copyright notice and disclaimer as to the original iAnywhere code.
# 
#######################################################################

import adsdb

# Adjust the connection path (C:\) and server type as necessary
conn = adsdb.connect(DataSource='c:\\', ServerType='local or remote')
cur = conn.cursor()

cur.execute("select 'Hello World' from system.iota")
assert cur.fetchone()[0] > 0

conn.close()
print 'adsdb successfully installed.'