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

[FEAT]: SQL Connection preflight connection #3100

Open
davini-dev opened this issue Feb 4, 2025 · 1 comment
Open

[FEAT]: SQL Connection preflight connection #3100

davini-dev opened this issue Feb 4, 2025 · 1 comment
Assignees
Labels
enhancement New feature or request feature request

Comments

@davini-dev
Copy link

What would you like to see?

There could be a button to test before saving the database connection.

Thanks

@davini-dev davini-dev added enhancement New feature or request feature request labels Feb 4, 2025
@timothycarambat timothycarambat changed the title [FEAT]: ASK SAVING [FEAT]: SQL Connection prelight connection Feb 4, 2025
@mainifestion1
Copy link

Here's a simple example of a SQL connection prelight feature implemented in Python:

import sqlite3
import threading

class SQLConnectionPrelight:
    def __init__(self, db_path):
        self.db_path = db_path
        self.connection = None
        self.lock = threading.Lock()

    def prelight_connection(self):
        with self.lock:
            if self.connection is None:
                self.connection = sqlite3.connect(self.db_path)
                print("Prelight connection established")

    def get_connection(self):
        with self.lock:
            if self.connection is None:
                self.prelight_connection()
            return self.connection

    def close_connection(self):
        with self.lock:
            if self.connection is not None:
                self.connection.close()
                self.connection = None
                print("Connection closed")

# Example usage
db_path = "example.db"
prelight_connection = SQLConnectionPrelight(db_path)

# Establish prelight connection
prelight_connection.prelight_connection()

# Get connection
connection = prelight_connection.get_connection()

# Use connection
cursor = connection.cursor()
cursor.execute("SELECT * FROM example_table")
results = cursor.fetchall()
print(results)

# Close connection
prelight_connection.close_connection()

@timothycarambat timothycarambat changed the title [FEAT]: SQL Connection prelight connection [FEAT]: SQL Connection preflight connection Feb 10, 2025
@timothycarambat timothycarambat self-assigned this Feb 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request feature request
Projects
None yet
Development

No branches or pull requests

3 participants