@@ -63,7 +63,7 @@ def _get_connection_kwargs(self) -> dict: # TODO move to `core.py`
6363
6464 return kwargs
6565
66- async def connect (self ) -> None : # TODO as MySQL one?
66+ async def connect (self ) -> None :
6767 assert self ._pool is None , "DatabaseBackend is already running"
6868 kwargs = self ._get_connection_kwargs ()
6969 self ._pool = await aiopg .create_pool (
@@ -72,7 +72,6 @@ async def connect(self) -> None: # TODO as MySQL one?
7272 user = self ._database_url .username or getpass .getuser (),
7373 password = self ._database_url .password ,
7474 database = self ._database_url .database ,
75- # autocommit=True,
7675 ** kwargs ,
7776 )
7877
@@ -112,8 +111,6 @@ async def fetch_all(self, query: ClauseElement) -> typing.List[typing.Mapping]:
112111 assert self ._connection is not None , "Connection is not acquired"
113112 query , args , context = self ._compile (query )
114113 cursor = await self ._connection .cursor ()
115- # TODO
116- import pdb ; pdb .set_trace ()
117114 try :
118115 await cursor .execute (query , args )
119116 rows = await cursor .fetchall ()
@@ -129,8 +126,6 @@ async def fetch_one(self, query: ClauseElement) -> typing.Optional[typing.Mappin
129126 assert self ._connection is not None , "Connection is not acquired"
130127 query , args , context = self ._compile (query )
131128 cursor = await self ._connection .cursor ()
132- # TODO
133- import pdb ; pdb .set_trace ()
134129 try :
135130 await cursor .execute (query , args )
136131 row = await cursor .fetchone ()
@@ -145,8 +140,6 @@ async def execute(self, query: ClauseElement) -> typing.Any:
145140 assert self ._connection is not None , "Connection is not acquired"
146141 query , args , context = self ._compile (query )
147142 cursor = await self ._connection .cursor ()
148- # TODO
149- import pdb ; pdb .set_trace ()
150143 try :
151144 await cursor .execute (query , args )
152145 return cursor .lastrowid
@@ -156,8 +149,6 @@ async def execute(self, query: ClauseElement) -> typing.Any:
156149 async def execute_many (self , queries : typing .List [ClauseElement ]) -> None :
157150 assert self ._connection is not None , "Connection is not acquired"
158151 cursor = await self ._connection .cursor ()
159- # TODO
160- import pdb ; pdb .set_trace ()
161152 try :
162153 for single_query in queries :
163154 single_query , args , context = self ._compile (single_query )
@@ -171,8 +162,6 @@ async def iterate(
171162 assert self ._connection is not None , "Connection is not acquired"
172163 query , args , context = self ._compile (query )
173164 cursor = await self ._connection .cursor ()
174- # TODO
175- import pdb ; pdb .set_trace ()
176165 try :
177166 await cursor .execute (query , args )
178167 metadata = ResultMetaData (context , cursor .description )
@@ -217,17 +206,14 @@ def __init__(self, connection: AiopgConnection):
217206 self ._savepoint_name = ""
218207
219208 async def start (self , is_root : bool ) -> None :
220- import pdb ; pdb .set_trace ()
221209 assert self ._connection ._connection is not None , "Connection is not acquired"
222210 self ._is_root = is_root
223211 cursor = await self ._connection ._connection .cursor ()
224212 if self ._is_root :
225- # await self._connection._connection.begin()
226213 await cursor .execute ("BEGIN" )
227214 else :
228215 id = str (uuid .uuid4 ()).replace ("-" , "_" )
229216 self ._savepoint_name = f"STARLETTE_SAVEPOINT_{ id } "
230- # cursor = await self._connection._connection.cursor()
231217 try :
232218 await cursor .execute (f"SAVEPOINT { self ._savepoint_name } " )
233219 finally :
@@ -237,10 +223,8 @@ async def commit(self) -> None:
237223 assert self ._connection ._connection is not None , "Connection is not acquired"
238224 cursor = await self ._connection ._connection .cursor ()
239225 if self ._is_root :
240- # await self._connection._connection.commit()
241226 await cursor .execute ("COMMIT" )
242227 else :
243- # cursor = await self._connection._connection.cursor()
244228 try :
245229 await cursor .execute (f"RELEASE SAVEPOINT { self ._savepoint_name } " )
246230 finally :
@@ -250,10 +234,8 @@ async def rollback(self) -> None:
250234 assert self ._connection ._connection is not None , "Connection is not acquired"
251235 cursor = await self ._connection ._connection .cursor ()
252236 if self ._is_root :
253- # await self._connection._connection.rollback()
254237 await cursor .execute ("ROLLBACK" )
255238 else :
256- # cursor = await self._connection._connection.cursor()
257239 try :
258240 await cursor .execute (f"ROLLBACK TO SAVEPOINT { self ._savepoint_name } " )
259241 finally :
0 commit comments