Skip to content

Commit 06b1aef

Browse files
Antony BaileyAntony Bailey
authored andcommitted
all local linting passes
1 parent 7fe77ff commit 06b1aef

File tree

11 files changed

+54
-30
lines changed

11 files changed

+54
-30
lines changed

src/pysqly/connectors/base.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ def execute(self, sql: str, params: List[Any]) -> Any:
5151
If the SQL statement is not a SELECT query, returns a success message.
5252
5353
Raises:
54-
SQLYExecutionError: If an error occurs during the execution of the SQL statement.
54+
SQLYExecutionError: If an error occurs during the execution of
55+
the SQL statement.
5556
"""
5657
cursor = self.connection.cursor()
5758
try:
@@ -61,6 +62,8 @@ def execute(self, sql: str, params: List[Any]) -> Any:
6162
self.connection.commit()
6263
return "Query executed successfully"
6364
except Exception as e:
64-
raise SQLYExecutionError(f"{self.__class__.__name__} error: {str(e)}") from e
65+
raise SQLYExecutionError(
66+
f"{self.__class__.__name__} error: {str(e)}"
67+
) from e
6568
finally:
6669
cursor.close()

src/pysqly/connectors/database.py

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,31 @@
77

88
class DatabaseConnector:
99
"""
10-
A class that manages connections to various database types and executes SQLY queries.
10+
A class that manages connections to various database types and executes
11+
SQLY queries.
1112
1213
This class serves as an abstraction layer over different database connectors,
13-
allowing for a unified interface to execute queries across different database systems
14-
such as SQLite, MariaDB, PostgreSQL, Oracle, and MS SQL Server.
14+
allowing for a unified interface to execute queries across different
15+
database systems such as SQLite, MariaDB, PostgreSQL, Oracle,
16+
and MS SQL Server.
1517
1618
Attributes:
1719
db_type: The type of the database being connected to.
18-
connection: The connection parameters or object needed to establish a database connection.
19-
connector: The actual database connector instance used to interact with the database.
20+
connection: The connection parameters or object needed to establish a
21+
connection.
22+
connector: The actual database connector instance used to interact with
23+
the database.
2024
2125
Examples:
2226
>>> connector = DatabaseConnector("sqlite", ":memory:")
23-
>>> result = connector.execute_query({"select": ["id", "name"], "from": "users"})
27+
>>> result = connector.execute_query({"select": ["id", "name"],
28+
"from": "users"})
2429
"""
2530

2631
def __init__(self, db_type: str, connection: Any) -> None:
2732
"""
28-
Initialize the DatabaseConnector with the database type and connection information.
33+
Initialize the DatabaseConnector with the database type and connection
34+
information.
2935
3036
Args:
3137
db_type: The type of the database (e.g., "sqlite", "mariadb",
@@ -69,7 +75,8 @@ def execute_query(
6975
The result of the executed query.
7076
7177
Raises:
72-
SQLYExecutionError: If the query is invalid or an error occurs during execution.
78+
SQLYExecutionError: If the query is invalid or an error occurs during
79+
execution.
7380
"""
7481
# Use provided values or fall back to instance attributes
7582
db_type = db_type or self.db_type

src/pysqly/connectors/factory.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class DBConnectorFactory:
2222
@staticmethod
2323
def create_connector(db_type: str, connection: Any) -> Any:
2424
"""
25-
Create and return a database connector instance based on the specified database type.
25+
Create and return a database connector instance based on the database type.
2626
2727
Args:
2828
db_type: The type of the database (e.g., "sqlite", "mariadb",

src/pysqly/connectors/interface.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,16 @@ def execute(self, sql: str, params: List[Any]) -> Any:
1919
"""
2020
Execute a SQL query with parameters.
2121
22-
This method executes a SQL query with the provided parameters against the database.
22+
This method executes a SQL query with the provided parameters against the
23+
database.
2324
2425
Args:
2526
sql: The SQL query to execute.
2627
params: The parameters to be used in the SQL query.
2728
2829
Returns:
29-
The result of the query execution, which depends on the specific database implementation.
30+
The result of the query execution, which depends on the specific database
31+
implementation.
3032
3133
Raises:
3234
DatabaseError: If the query execution fails.

src/pysqly/connectors/mariadb.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,13 @@ def __init__(self, connection: Union[str, Any]) -> None:
1818
"""
1919
Initialize the MariaDBConnector.
2020
21-
This constructor accepts either a connection string or an existing MySQL connection.
21+
This constructor accepts either a connection string or an existing
22+
MySQL connection.
2223
2324
Args:
24-
connection: If a string is provided, it's treated as a connection string and a new connection is established.
25-
If a connection object is provided, it's used directly.
25+
connection: If a string is provided, it's treated as a connection string
26+
and a new connection is established. If a connection object is provided,
27+
it's used directly.
2628
"""
2729
if isinstance(connection, str):
2830
connection = mysql.connector.connect(connection)

src/pysqly/connectors/mssql.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@ def __init__(self, connection: Union[str, Any]) -> None:
2424
establish a new connection.
2525
2626
Notes:
27-
If a connection string is provided, it should be in the format required by pyodbc,
28-
typically including server, database, authentication details, and other relevant parameters.
27+
If a connection string is provided, it should be in the format required by
28+
pyodbc, typically including server, database, authentication details,
29+
and other relevant parameters.
2930
"""
3031
if isinstance(connection, str):
3132
connection = pyodbc.connect(connection)

src/pysqly/connectors/oracle.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,10 @@ def __init__(self, connection: Union[str, Any]) -> None:
2121
This constructor initializes a connection to an Oracle database using cx_Oracle.
2222
2323
Args:
24-
connection: Either a connection string in the format "username/password@host:port/service_name"
25-
or an already established cx_Oracle Connection object.
26-
If a string is provided, it will be used to create a new connection.
24+
connection: Either a connection string in the format
25+
"username/password@host:port/service_name" or an already established
26+
cx_Oracle Connection object. If a string is provided, it will be used
27+
to create a new connection.
2728
2829
Notes:
2930
The connection string format follows the Oracle standard:

src/pysqly/connectors/postgres.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ def __init__(self, connection: Union[str, Any]) -> None:
2020
2121
Args:
2222
connection: Either a connection string to establish a new connection
23-
or an existing psycopg2 connection object. If a string is provided, it will be used to create
24-
a new connection.
23+
or an existing psycopg2 connection object. If a string is provided,
24+
it will be used to create a new connection.
2525
2626
Notes:
2727
The connection string should be in the format:

src/pysqly/connectors/sqlite.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@ def __init__(self, connection: Union[str, sqlite3.Connection]) -> None:
1818
Initialize the SQLiteConnector with a connection to an SQLite database.
1919
2020
Args:
21-
connection: Either a file path to an SQLite database or an existing sqlite3.Connection object.
22-
If a string is provided, a new connection to the database at that path is created.
21+
connection: Either a file path to an SQLite database or an existing
22+
sqlite3.Connection object. If a string is provided, a new connection
23+
to the database at that path is created.
2324
"""
2425
if isinstance(connection, str):
2526
connection = sqlite3.connect(connection)

src/pysqly/core/executor.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,9 @@ def execute(self, query: str) -> Any:
5858
)
5959
return self._run_query(parsed_query)
6060
except Exception as e:
61-
raise SQLYExecutionError(f"Failed to process SQLY query: {str(e)}") from e
61+
raise SQLYExecutionError(
62+
f"Failed to process SQLY query: {str(e)}"
63+
) from e
6264

6365
def _run_query(self, parsed_query: Dict[str, Any]) -> Any:
6466
"""
@@ -75,7 +77,9 @@ def _run_query(self, parsed_query: Dict[str, Any]) -> Any:
7577
"""
7678
try:
7779
if not self.db_connector:
78-
raise SQLYExecutionError("Database type not specified for the executor.")
80+
raise SQLYExecutionError(
81+
"Database type not specified for the executor."
82+
)
7983

8084
return self.db_connector.execute_query(parsed_query)
8185
except Exception as e:

0 commit comments

Comments
 (0)