Coverage for src/sqlqb/mysql/__init__.py: 0%
26 statements
« prev ^ index » next coverage.py v7.14.1, created at 2026-06-20 15:56 +0200
« prev ^ index » next coverage.py v7.14.1, created at 2026-06-20 15:56 +0200
1from pymysql.connections import Connection as _Connection
2from pymysql.cursors import DictCursor
4from sqlqb import Select as _Select
7class Select(_Select):
8 def __init__(self, connection, *args, **kwargs):
9 self.__connection = connection
10 super().__init__(*args, **kwargs)
12 def fetchone(self, cursor=None):
13 cursor = cursor or self.__connection.cursor()
14 with cursor as cursor:
15 cursor.execute(self.sql, self.params)
16 result = cursor.fetchone()
17 return result
19 def fetchall(self, cursor=None):
20 cursor = cursor or self.__connection.cursor()
21 with cursor as cursor:
22 cursor.execute(self.sql, self.params)
23 result = cursor.fetchall()
24 return result
27class Connection(_Connection):
28 def __init__(self, *args, **kwargs):
29 if "cursorclass" not in kwargs:
30 kwargs["cursorclass"] = DictCursor
31 super().__init__(*args, **kwargs)
33 def Select(self, *args, **kwargs):
34 return Select(self, *args, **kwargs)