Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Connexion to Terdata are not closed #445

Closed
KevinMendesCGI opened this issue Apr 14, 2022 · 0 comments
Closed

Connexion to Terdata are not closed #445

KevinMendesCGI opened this issue Apr 14, 2022 · 0 comments
Assignees
Labels
priority: p1 High priority. Fix may be included in the next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@KevinMendesCGI
Copy link

KevinMendesCGI commented Apr 14, 2022

Hello, I am telling you about a problem encountered on a move2cloud Teradata to GCP project.

Objective of our tests:

Check the validity of data between more than 9000 Teradata and GCP tables.

Desired result of the tool:

The data validation tool, launched individually for each table, must report the results of the comparisons between 2 tables, all over an iteration of approximately 9000 tables. At the end of a comparison, the connection to the database must be cut.

Result obtained:

After several hundred tables compared, the connections not being closed, these connections go into "idle" on Teradata causing a connection overload making it impossible to connect to the database with all the consequences related to this overload

proposition of a solution:

The teradatasql library has a .close() method which should solve this problem.

you could close the connection by destroying the object after sending results. This method would not cause conflict with other client's methods.

On https://github.com/KevinMendesCGI/professional-services-data-validator/blob/ad7f1fcfc10541cf19044a1bf88d16deb1398772/third_party/ibis/ibis_teradata/client.py#L61-L98

class TeradataClient(SQLClient):
    """ An ibis Teradata client implementation """

    query_class = TeradataQuery
    database_class = TeradataDatabase
    table_class = TeradataTable
    dialect = compiler.TeradataDialect

    def __init__(self, host, user_name, password, port=1025, logmech='TD2', use_no_lock_tables=False):
        """Construct a TeradataClient.

        Parameters
        ----------
        host : str
            The Database host to connect to
        user_name : str
            A Database username to connect with
        password : str
            Password for supplied username
        port : Optional[int]
            The database port to connect to (default. 1025)
        logmech : Optional[int]
            The logmech type to connect to (default. TD2)
        """
        self.teradata_config = {
            "host": host,
            "user": user_name,
            "password": password,
            "dbs_port": port,
            "logmech": logmech,
        }

        self.client = teradatasql.connect(**self.teradata_config)
        self.use_no_lock_tables = use_no_lock_tables


    def __del__ (self):
        teradatasql.close()

By using del object the connexion will be close

@nehanene15 nehanene15 added type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. priority: p1 High priority. Fix may be included in the next release. labels Jun 1, 2022
@latika-wadhwa latika-wadhwa self-assigned this Jun 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: p1 High priority. Fix may be included in the next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

No branches or pull requests

3 participants