MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / _reap_oracle_dbs

Function _reap_oracle_dbs

lib/sqlalchemy/dialects/oracle/provision.py:226–255  ·  view source on GitHub ↗
(url, idents)

Source from the content-addressed store, hash-verified

224
225@run_reap_dbs.for_db("oracle")
226def _reap_oracle_dbs(url, idents):
227 log.info("db reaper connecting to %r", url)
228 eng = create_engine(url)
229 with eng.begin() as conn:
230 log.info("identifiers in file: %s", ", ".join(idents))
231
232 to_reap = conn.exec_driver_sql(
233 "select u.username from all_users u where username "
234 "like 'TEST_%' and not exists (select username "
235 "from v$session where username=u.username)"
236 )
237 all_names = {username.lower() for (username,) in to_reap}
238 to_drop = set()
239 for name in all_names:
240 if name.endswith("_ts1") or name.endswith("_ts2"):
241 continue
242 elif name in idents:
243 to_drop.add(name)
244 if "%s_ts1" % name in all_names:
245 to_drop.add("%s_ts1" % name)
246 if "%s_ts2" % name in all_names:
247 to_drop.add("%s_ts2" % name)
248
249 dropped = total = 0
250 for total, username in enumerate(to_drop, 1):
251 if _ora_drop_ignore(conn, username):
252 dropped += 1
253 log.info(
254 "Dropped %d out of %d stale databases detected", dropped, total
255 )
256
257
258@follower_url_from_main.for_db("oracle")

Callers

nothing calls this directly

Calls 9

create_engineFunction · 0.85
_ora_drop_ignoreFunction · 0.85
lowerMethod · 0.80
infoMethod · 0.45
beginMethod · 0.45
joinMethod · 0.45
exec_driver_sqlMethod · 0.45
endswithMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected