-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Denodo integration for multimodal trading bot (#19)
Related to #18 Add Denodo integration to the repository. * **Denodo Integration Module** - Add `denodo_integration.py` to establish Denodo connection using `jaydebeapi` or `pyodbc`. - Implement utility functions for executing queries and retrieving results. - Include error handling and logging for connection and query issues. * **Configuration Updates** - Update `config/api_config.py` to include Denodo-related configurations and headers. - Update `config/config.py` to include Denodo configurations in the main configuration settings. - Add Denodo-related environment variables to `.env`. * **Main Application Changes** - Update `main.py` to initialize Denodo connection and utilize it for data retrieval and processing. - Add Denodo query execution in the asynchronous data processing function. * **Dependencies** - Update `requirements.txt` to include `jaydebeapi` and `pyodbc` libraries for Denodo integration. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Added Denodo database integration to the application - Introduced new configuration options for Denodo API connection - Implemented methods to connect and execute queries with Denodo database - **Dependencies** - Added `jaydebeapi` and `pyodbc` libraries for database connectivity - **Configuration** - Added new environment variables for Denodo API configuration - Updated configuration management to support Denodo connection parameters <!-- end of auto-generated comment: release notes by coderabbit.ai -->
- Loading branch information
Showing
6 changed files
with
126 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import os | ||
import jaydebeapi | ||
import logging | ||
from dotenv import load_dotenv | ||
|
||
# Load environment variables from .env file | ||
load_dotenv() | ||
|
||
# Configure logging | ||
logger = logging.getLogger(__name__) | ||
logger.setLevel(logging.INFO) | ||
handler = logging.StreamHandler() | ||
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s') | ||
handler.setFormatter(formatter) | ||
logger.addHandler(handler) | ||
|
||
class DenodoIntegration: | ||
def __init__(self): | ||
self.connection = None | ||
self.cursor = None | ||
self.connect() | ||
|
||
def connect(self): | ||
try: | ||
denodo_host = os.getenv("DENODO_HOST") | ||
denodo_port = os.getenv("DENODO_PORT") | ||
denodo_database = os.getenv("DENODO_DATABASE") | ||
denodo_username = os.getenv("DENODO_USERNAME") | ||
denodo_password = os.getenv("DENODO_PASSWORD") | ||
denodo_jdbc_driver = os.getenv("DENODO_JDBC_DRIVER") | ||
|
||
url = f"jdbc:denodo://{denodo_host}:{denodo_port}/{denodo_database}" | ||
self.connection = jaydebeapi.connect( | ||
"com.denodo.vdp.jdbc.Driver", | ||
url, | ||
[denodo_username, denodo_password], | ||
denodo_jdbc_driver | ||
) | ||
self.cursor = self.connection.cursor() | ||
logger.info("Connected to Denodo successfully") | ||
except Exception as e: | ||
logger.error(f"Failed to connect to Denodo: {str(e)}") | ||
raise | ||
|
||
def execute_query(self, query, params=None): | ||
try: | ||
if params: | ||
self.cursor.execute(query, params) | ||
else: | ||
self.cursor.execute(query) | ||
result = self.cursor.fetchall() | ||
return result | ||
except Exception as e: | ||
logger.error(f"Failed to execute query: {str(e)}") | ||
raise | ||
|
||
def close(self): | ||
try: | ||
if self.cursor: | ||
self.cursor.close() | ||
if self.connection: | ||
self.connection.close() | ||
logger.info("Closed Denodo connection") | ||
except Exception as e: | ||
logger.error(f"Failed to close Denodo connection: {str(e)}") | ||
raise |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,3 +12,5 @@ mypy>=1.4.1 | |
black>=23.3.0 | ||
isort>=5.12.0 | ||
flake8>=6.0.0 | ||
jaydebeapi>=1.2.3 | ||
pyodbc>=4.0.32 |