database-wrapper-mysql 0.2.17__tar.gz → 0.2.23__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {database_wrapper_mysql-0.2.17 → database_wrapper_mysql-0.2.23}/PKG-INFO +2 -2
- {database_wrapper_mysql-0.2.17 → database_wrapper_mysql-0.2.23}/database_wrapper_mysql/__init__.py +7 -6
- {database_wrapper_mysql-0.2.17 → database_wrapper_mysql-0.2.23}/database_wrapper_mysql/connector.py +19 -11
- {database_wrapper_mysql-0.2.17 → database_wrapper_mysql-0.2.23}/database_wrapper_mysql/db_wrapper_mysql.py +8 -8
- {database_wrapper_mysql-0.2.17 → database_wrapper_mysql-0.2.23}/database_wrapper_mysql.egg-info/PKG-INFO +2 -2
- database_wrapper_mysql-0.2.23/database_wrapper_mysql.egg-info/requires.txt +2 -0
- {database_wrapper_mysql-0.2.17 → database_wrapper_mysql-0.2.23}/pyproject.toml +5 -10
- database_wrapper_mysql-0.2.17/database_wrapper_mysql.egg-info/requires.txt +0 -2
- {database_wrapper_mysql-0.2.17 → database_wrapper_mysql-0.2.23}/README.md +0 -0
- {database_wrapper_mysql-0.2.17 → database_wrapper_mysql-0.2.23}/database_wrapper_mysql/py.typed +0 -0
- {database_wrapper_mysql-0.2.17 → database_wrapper_mysql-0.2.23}/database_wrapper_mysql.egg-info/SOURCES.txt +0 -0
- {database_wrapper_mysql-0.2.17 → database_wrapper_mysql-0.2.23}/database_wrapper_mysql.egg-info/dependency_links.txt +0 -0
- {database_wrapper_mysql-0.2.17 → database_wrapper_mysql-0.2.23}/database_wrapper_mysql.egg-info/top_level.txt +0 -0
- {database_wrapper_mysql-0.2.17 → database_wrapper_mysql-0.2.23}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: database_wrapper_mysql
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.23
|
|
4
4
|
Summary: database_wrapper for MySQL database
|
|
5
5
|
Author-email: Gints Murans <gm@gm.lv>
|
|
6
6
|
License: GNU General Public License v3.0 (GPL-3.0)
|
|
@@ -32,7 +32,7 @@ Classifier: Topic :: Software Development
|
|
|
32
32
|
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
33
33
|
Requires-Python: >=3.8
|
|
34
34
|
Description-Content-Type: text/markdown
|
|
35
|
-
Requires-Dist: database_wrapper==0.2.
|
|
35
|
+
Requires-Dist: database_wrapper==0.2.23
|
|
36
36
|
Requires-Dist: mysqlclient>=2.2.2
|
|
37
37
|
|
|
38
38
|
# database_wrapper_mysql
|
{database_wrapper_mysql-0.2.17 → database_wrapper_mysql-0.2.23}/database_wrapper_mysql/__init__.py
RENAMED
|
@@ -8,7 +8,7 @@ Part of the database_wrapper package
|
|
|
8
8
|
|
|
9
9
|
import logging
|
|
10
10
|
|
|
11
|
-
from .connector import
|
|
11
|
+
from .connector import Mysql, MysqlConfig, MysqlConnection, MysqlDictCursor, MysqlTypedDictCursor
|
|
12
12
|
from .db_wrapper_mysql import DBWrapperMysql
|
|
13
13
|
|
|
14
14
|
# Set the logger to a quiet default, can be enabled if needed
|
|
@@ -19,12 +19,13 @@ if logger.level == logging.NOTSET:
|
|
|
19
19
|
|
|
20
20
|
__all__ = [
|
|
21
21
|
# Wrappers
|
|
22
|
-
|
|
22
|
+
DBWrapperMysql,
|
|
23
23
|
# Connectors
|
|
24
|
-
|
|
24
|
+
Mysql,
|
|
25
25
|
# Connection and Cursor types
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
MysqlConnection,
|
|
27
|
+
MysqlDictCursor,
|
|
28
|
+
MysqlTypedDictCursor,
|
|
28
29
|
# Helpers
|
|
29
|
-
|
|
30
|
+
MysqlConfig,
|
|
30
31
|
]
|
{database_wrapper_mysql-0.2.17 → database_wrapper_mysql-0.2.23}/database_wrapper_mysql/connector.py
RENAMED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
from typing import Any, NotRequired, TypedDict
|
|
2
2
|
|
|
3
|
-
from MySQLdb.connections import Connection as
|
|
4
|
-
from MySQLdb.cursors import DictCursor as
|
|
3
|
+
from MySQLdb.connections import Connection as MysqlConnection
|
|
4
|
+
from MySQLdb.cursors import DictCursor as MysqlDictCursor
|
|
5
5
|
|
|
6
6
|
from database_wrapper import DatabaseBackend
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
class
|
|
9
|
+
class MysqlConfig(TypedDict):
|
|
10
10
|
hostname: str
|
|
11
11
|
port: NotRequired[int]
|
|
12
12
|
username: str
|
|
@@ -17,12 +17,20 @@ class MyConfig(TypedDict):
|
|
|
17
17
|
kwargs: NotRequired[dict[str, Any]]
|
|
18
18
|
|
|
19
19
|
|
|
20
|
-
class
|
|
20
|
+
class MysqlTypedDictCursor(MysqlDictCursor):
|
|
21
|
+
def fetchone(self) -> dict[str, Any] | None:
|
|
22
|
+
return super().fetchone()
|
|
23
|
+
|
|
24
|
+
def fetchall(self) -> tuple[dict[str, Any], ...]:
|
|
25
|
+
return super().fetchall()
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
class Mysql(DatabaseBackend):
|
|
21
29
|
"""
|
|
22
30
|
MySQL database backend
|
|
23
31
|
|
|
24
32
|
:param config: Configuration for MySQL
|
|
25
|
-
:type config:
|
|
33
|
+
:type config: MysqlConfig
|
|
26
34
|
|
|
27
35
|
Defaults:
|
|
28
36
|
port = 0 - See comment below
|
|
@@ -30,10 +38,10 @@ class MySQL(DatabaseBackend):
|
|
|
30
38
|
collation = utf8_general_ci
|
|
31
39
|
"""
|
|
32
40
|
|
|
33
|
-
config:
|
|
41
|
+
config: MysqlConfig
|
|
34
42
|
|
|
35
|
-
connection:
|
|
36
|
-
cursor:
|
|
43
|
+
connection: MysqlConnection
|
|
44
|
+
cursor: MysqlTypedDictCursor
|
|
37
45
|
|
|
38
46
|
##################
|
|
39
47
|
### Connection ###
|
|
@@ -58,7 +66,7 @@ class MySQL(DatabaseBackend):
|
|
|
58
66
|
self.config["kwargs"] = {}
|
|
59
67
|
|
|
60
68
|
self.logger.debug("Connecting to DB")
|
|
61
|
-
self.connection =
|
|
69
|
+
self.connection = MysqlConnection(
|
|
62
70
|
host=self.config["hostname"],
|
|
63
71
|
user=self.config["username"],
|
|
64
72
|
passwd=self.config["password"],
|
|
@@ -77,11 +85,11 @@ class MySQL(DatabaseBackend):
|
|
|
77
85
|
use_unicode=True,
|
|
78
86
|
charset=self.config["charset"],
|
|
79
87
|
collation=self.config["collation"],
|
|
80
|
-
cursorclass=
|
|
88
|
+
cursorclass=MysqlTypedDictCursor,
|
|
81
89
|
**self.config["kwargs"],
|
|
82
90
|
)
|
|
83
91
|
# TODO: Typings issue
|
|
84
|
-
self.cursor = self.connection.cursor(
|
|
92
|
+
self.cursor = self.connection.cursor(MysqlTypedDictCursor)
|
|
85
93
|
|
|
86
94
|
def ping(self) -> bool:
|
|
87
95
|
try:
|
|
@@ -3,13 +3,13 @@ from typing import Any
|
|
|
3
3
|
|
|
4
4
|
from database_wrapper import DBWrapper
|
|
5
5
|
|
|
6
|
-
from .connector import
|
|
6
|
+
from .connector import MysqlTypedDictCursor
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
class DBWrapperMysql(DBWrapper):
|
|
10
10
|
"""Wrapper for MySQL database"""
|
|
11
11
|
|
|
12
|
-
db_cursor:
|
|
12
|
+
db_cursor: MysqlTypedDictCursor | None
|
|
13
13
|
""" MySQL cursor object """
|
|
14
14
|
|
|
15
15
|
#######################
|
|
@@ -20,14 +20,14 @@ class DBWrapperMysql(DBWrapper):
|
|
|
20
20
|
# We are overriding the __init__ method for the type hinting
|
|
21
21
|
def __init__(
|
|
22
22
|
self,
|
|
23
|
-
db_cursor:
|
|
23
|
+
db_cursor: MysqlTypedDictCursor | None = None,
|
|
24
24
|
logger: logging.Logger | None = None,
|
|
25
25
|
):
|
|
26
26
|
"""
|
|
27
27
|
Initializes a new instance of the DBWrapper class.
|
|
28
28
|
|
|
29
29
|
Args:
|
|
30
|
-
db_cursor (
|
|
30
|
+
db_cursor (MysqlTypedDictCursor): The MySQL database cursor object.
|
|
31
31
|
logger (logging.Logger, optional): The logger object. Defaults to None.
|
|
32
32
|
"""
|
|
33
33
|
super().__init__(db_cursor, logger)
|
|
@@ -36,12 +36,12 @@ class DBWrapperMysql(DBWrapper):
|
|
|
36
36
|
### Setters ###
|
|
37
37
|
###############
|
|
38
38
|
|
|
39
|
-
def set_db_cursor(self, db_cursor:
|
|
39
|
+
def set_db_cursor(self, db_cursor: MysqlTypedDictCursor | None) -> None:
|
|
40
40
|
"""
|
|
41
41
|
Updates the database cursor object.
|
|
42
42
|
|
|
43
43
|
Args:
|
|
44
|
-
db_cursor (
|
|
44
|
+
db_cursor (MysqlTypedDictCursor): The new database cursor object.
|
|
45
45
|
"""
|
|
46
46
|
super().set_db_cursor(db_cursor)
|
|
47
47
|
|
|
@@ -51,7 +51,7 @@ class DBWrapperMysql(DBWrapper):
|
|
|
51
51
|
|
|
52
52
|
def log_query(
|
|
53
53
|
self,
|
|
54
|
-
cursor:
|
|
54
|
+
cursor: MysqlTypedDictCursor,
|
|
55
55
|
query: Any,
|
|
56
56
|
params: tuple[Any, ...],
|
|
57
57
|
) -> None:
|
|
@@ -59,7 +59,7 @@ class DBWrapperMysql(DBWrapper):
|
|
|
59
59
|
Logs the given query and parameters.
|
|
60
60
|
|
|
61
61
|
Args:
|
|
62
|
-
cursor (
|
|
62
|
+
cursor (MysqlTypedDictCursor): The cursor used to execute the query.
|
|
63
63
|
query (Any): The query to log.
|
|
64
64
|
params (tuple[Any, ...]): The parameters to log.
|
|
65
65
|
"""
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: database_wrapper_mysql
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.23
|
|
4
4
|
Summary: database_wrapper for MySQL database
|
|
5
5
|
Author-email: Gints Murans <gm@gm.lv>
|
|
6
6
|
License: GNU General Public License v3.0 (GPL-3.0)
|
|
@@ -32,7 +32,7 @@ Classifier: Topic :: Software Development
|
|
|
32
32
|
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
33
33
|
Requires-Python: >=3.8
|
|
34
34
|
Description-Content-Type: text/markdown
|
|
35
|
-
Requires-Dist: database_wrapper==0.2.
|
|
35
|
+
Requires-Dist: database_wrapper==0.2.23
|
|
36
36
|
Requires-Dist: mysqlclient>=2.2.2
|
|
37
37
|
|
|
38
38
|
# database_wrapper_mysql
|
|
@@ -4,14 +4,12 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "database_wrapper_mysql"
|
|
7
|
-
version = "0.2.
|
|
7
|
+
version = "0.2.23"
|
|
8
8
|
description = "database_wrapper for MySQL database"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.8"
|
|
11
|
-
license = {text = "GNU General Public License v3.0 (GPL-3.0)"}
|
|
12
|
-
authors = [
|
|
13
|
-
{name = "Gints Murans", email = "gm@gm.lv"}
|
|
14
|
-
]
|
|
11
|
+
license = { text = "GNU General Public License v3.0 (GPL-3.0)" }
|
|
12
|
+
authors = [{ name = "Gints Murans", email = "gm@gm.lv" }]
|
|
15
13
|
classifiers = [
|
|
16
14
|
"Development Status :: 4 - Beta",
|
|
17
15
|
"Intended Audience :: Developers",
|
|
@@ -31,13 +29,10 @@ classifiers = [
|
|
|
31
29
|
"Topic :: Database",
|
|
32
30
|
"Topic :: Database :: Front-Ends",
|
|
33
31
|
"Topic :: Software Development",
|
|
34
|
-
"Topic :: Software Development :: Libraries :: Python Modules"
|
|
32
|
+
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
35
33
|
]
|
|
36
34
|
keywords = ["database", "wrapper", "python", "mysql", "mariadb"]
|
|
37
|
-
dependencies = [
|
|
38
|
-
"database_wrapper == 0.2.17",
|
|
39
|
-
"mysqlclient >= 2.2.2"
|
|
40
|
-
]
|
|
35
|
+
dependencies = ["database_wrapper == 0.2.23", "mysqlclient >= 2.2.2"]
|
|
41
36
|
|
|
42
37
|
[project.urls]
|
|
43
38
|
Homepage = "https://github.com/gintsmurans/py_database_wrapper"
|
|
File without changes
|
{database_wrapper_mysql-0.2.17 → database_wrapper_mysql-0.2.23}/database_wrapper_mysql/py.typed
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|