-
Notifications
You must be signed in to change notification settings - Fork 5k
support stmt2 test cases #32533
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
support stmt2 test cases #32533
Conversation
tomchon
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
test/cases/demo/test_stmt2.py
Outdated
| def setup_class(cls): | ||
| tdLog.debug("start to execute %s" % __file__) | ||
|
|
||
| def newcon(self, host, cfg): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
使用默认的连接,按着 tdSql 的逻辑,提供一个 tdStmt2 的初始化实例。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
已修改
test/cases/demo/test_stmt2.py
Outdated
| stmt.close() | ||
|
|
||
| # Test 2: Batch insert using stmt2 | ||
| stmt = TDStmt2(conn) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
使用默认的 tdStmt2 的实例,提两种绑定写入的方法,
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
已修改
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This pull request adds support for TDengine's stmt2 API in the test framework by introducing a new utility class TDStmt2 with comprehensive methods for prepared statement operations. The implementation provides a convenient interface for single row inserts, batch operations, and super table data binding with proper error handling and logging.
Key changes:
- Introduces
TDStmt2utility class with method chaining support and context manager functionality - Adds comprehensive parameter binding methods for different use cases (single, batch, super table)
- Integrates stmt2 functionality into the test framework's initialization process
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| test/new_test_framework/utils/stmt2.py | New utility class implementing TDengine stmt2 API wrapper with prepare, bind, and execute methods |
| test/new_test_framework/utils/init.py | Exports TDStmt2 class for framework-wide usage |
| test/conftest.py | Initializes global tdStmt2 instance in test setup |
| test/cases/demo/test_stmt2.py | Demo test case showcasing stmt2 API usage patterns |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.
| if self.stmt: | ||
| try: | ||
| self.stmt.close() | ||
| except: |
Copilot
AI
Aug 13, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using bare except: clause is discouraged as it catches all exceptions including system exit and keyboard interrupt. Consider catching specific exceptions or using except Exception: instead.
| except: | |
| except Exception: |
|
|
||
| class TDStmt2: | ||
| """ | ||
| TDengine Stmt2 utility class |
Copilot
AI
Aug 13, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a trailing space at the end of the docstring line.
| TDengine Stmt2 utility class | |
| TDengine Stmt2 utility class |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
import instance instead of class
Description
Please briefly describe the code changes in this pull request.
Checklist
Please check the items in the checklist if applicable.