From f969bdef4f3403e22b0a7bf84d0d4e86c2428a77 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 10 Dec 2023 11:18:47 +0100 Subject: Merging upstream version 1.10.0. Signed-off-by: Daniel Baumann --- litecli/sqlexecute.py | 29 +++++++---------------------- 1 file changed, 7 insertions(+), 22 deletions(-) (limited to 'litecli/sqlexecute.py') diff --git a/litecli/sqlexecute.py b/litecli/sqlexecute.py index 3f78d49..2392472 100644 --- a/litecli/sqlexecute.py +++ b/litecli/sqlexecute.py @@ -1,8 +1,8 @@ import logging import sqlite3 -import uuid from contextlib import closing from sqlite3 import OperationalError +from litecli.packages.special.utils import check_if_sqlitedotcommand import sqlparse import os.path @@ -18,7 +18,6 @@ _logger = logging.getLogger(__name__) class SQLExecute(object): - databases_query = """ PRAGMA database_list """ @@ -51,7 +50,6 @@ class SQLExecute(object): def __init__(self, database): self.dbname = database self._server_type = None - self.connection_id = None self.conn = None if not database: _logger.debug("Database is not specified. Skip connection.") @@ -76,8 +74,6 @@ class SQLExecute(object): # Update them after the connection is made to ensure that it was a # successful connection. self.dbname = db - # retrieve connection id - self.reset_connection_id() def run(self, statement): """Execute the sql in the database and return the results. The results @@ -129,9 +125,12 @@ class SQLExecute(object): for result in special.execute(cur, sql): yield result except special.CommandNotFound: # Regular SQL - _logger.debug("Regular sql statement. sql: %r", sql) - cur.execute(sql) - yield self.get_result(cur) + if check_if_sqlitedotcommand(sql): + yield ("dot command not implemented", None, None, None) + else: + _logger.debug("Regular sql statement. sql: %r", sql) + cur.execute(sql) + yield self.get_result(cur) def get_result(self, cursor): """Get the current result's data from the cursor.""" @@ -204,17 +203,3 @@ class SQLExecute(object): def server_type(self): self._server_type = ("sqlite3", "3") return self._server_type - - def get_connection_id(self): - if not self.connection_id: - self.reset_connection_id() - return self.connection_id - - def reset_connection_id(self): - # Remember current connection id - _logger.debug("Get current connection id") - # res = self.run('select connection_id()') - self.connection_id = uuid.uuid4() - # for title, cur, headers, status in res: - # self.connection_id = cur.fetchone()[0] - _logger.debug("Current connection id: %s", self.connection_id) -- cgit v1.2.3