reydb 1.1.49__py3-none-any.whl → 1.1.51__py3-none-any.whl

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.
reydb/rinfo.py CHANGED
@@ -11,10 +11,8 @@
11
11
 
12
12
  from __future__ import annotations
13
13
  from typing import Any, Literal, overload
14
- from reykit.rbase import throw
15
14
 
16
15
  from .rbase import DatabaseBase
17
- from .rconn import DatabaseConnection
18
16
  from .rdb import Database
19
17
 
20
18
 
@@ -151,11 +149,11 @@ class DatabaseInformation(DatabaseBase):
151
149
  # Build.
152
150
  match self:
153
151
  case DatabaseInformationSchema():
154
- table = DatabaseInformationDatabase(self._rdatabase, name)
152
+ table = DatabaseInformationDatabase(self.db, name)
155
153
  case DatabaseInformationDatabase():
156
- table = DatabaseInformationTable(self._rdatabase, self._database_name, name)
154
+ table = DatabaseInformationTable(self.db, self.database, name)
157
155
  case DatabaseInformationTable():
158
- table = DatabaseInformationColumn(self._rdatabase, self._database_name, self._table_name, name)
156
+ table = DatabaseInformationColumn(self.db, self.database, self.table, name)
159
157
  case _:
160
158
  raise AssertionError("class '%s' does not have this method" % type(self).__name__)
161
159
 
@@ -193,18 +191,18 @@ class DatabaseInformationSchema(DatabaseInformation):
193
191
 
194
192
  def __init__(
195
193
  self,
196
- rdatabase: Database | DatabaseConnection
194
+ db: Database
197
195
  ) -> None:
198
196
  """
199
197
  Build instance attributes.
200
198
 
201
199
  Parameters
202
200
  ----------
203
- rdatabase : Database or DatabaseConnection instance.
201
+ db: `Database` instance.
204
202
  """
205
203
 
206
204
  # Set parameter.
207
- self._rdatabase = rdatabase
205
+ self.db = db
208
206
 
209
207
 
210
208
  def _get_info_table(self) -> list[dict]:
@@ -217,7 +215,7 @@ class DatabaseInformationSchema(DatabaseInformation):
217
215
  """
218
216
 
219
217
  # Select.
220
- result = self._rdatabase.execute.select(
218
+ result = self.db.execute.select(
221
219
  'information_schema.SCHEMATA',
222
220
  order='`schema_name`'
223
221
  )
@@ -256,21 +254,21 @@ class DatabaseInformationDatabase(DatabaseInformation):
256
254
 
257
255
  def __init__(
258
256
  self,
259
- rdatabase: Database | DatabaseConnection,
260
- database_name: str
257
+ db: Database,
258
+ database: str
261
259
  ) -> None:
262
260
  """
263
261
  Build instance attributes.
264
262
 
265
263
  Parameters
266
264
  ----------
267
- rdatabase : Database or DatabaseConnection instance.
268
- database_name : Database name.
265
+ db: `Database` instance.
266
+ database : Database name.
269
267
  """
270
268
 
271
269
  # Set parameter.
272
- self._rdatabase = rdatabase
273
- self._database_name = database_name
270
+ self.db = db
271
+ self.database = database
274
272
 
275
273
 
276
274
  def _get_info_attrs(self) -> dict:
@@ -283,19 +281,19 @@ class DatabaseInformationDatabase(DatabaseInformation):
283
281
  """
284
282
 
285
283
  # Select.
286
- where = '`SCHEMA_NAME` = :database_name'
287
- result = self._rdatabase.execute.select(
284
+ where = '`SCHEMA_NAME` = :database'
285
+ result = self.db.execute.select(
288
286
  'information_schema.SCHEMATA',
289
287
  where=where,
290
288
  limit=1,
291
- database_name=self._database_name
289
+ database=self.database
292
290
  )
293
291
 
294
292
  # Convert.
295
293
  info_table = result.to_table()
296
294
 
297
295
  ## Check.
298
- assert len(info_table) != 0, "database '%s' not exist" % self._database_name
296
+ assert len(info_table) != 0, "database '%s' not exist" % self.database
299
297
 
300
298
  info_attrs = info_table[0]
301
299
 
@@ -312,19 +310,19 @@ class DatabaseInformationDatabase(DatabaseInformation):
312
310
  """
313
311
 
314
312
  # Select.
315
- where = '`TABLE_SCHEMA` = :database_name'
316
- result = self._rdatabase.execute.select(
313
+ where = '`TABLE_SCHEMA` = :database'
314
+ result = self.db.execute.select(
317
315
  'information_schema.TABLES',
318
316
  where=where,
319
317
  order='`TABLE_NAME`',
320
- database_name=self._database_name
318
+ database=self.database
321
319
  )
322
320
 
323
321
  # Convert.
324
322
  info_table = result.to_table()
325
323
 
326
324
  ## Check.
327
- assert len(info_table) != 0, "database '%s' not exist" % self._database_name
325
+ assert len(info_table) != 0, "database '%s' not exist" % self.database
328
326
 
329
327
  return info_table
330
328
 
@@ -351,24 +349,24 @@ class DatabaseInformationTable(DatabaseInformation):
351
349
 
352
350
  def __init__(
353
351
  self,
354
- rdatabase: Database | DatabaseConnection,
355
- database_name: str,
356
- table_name: str
352
+ db: Database,
353
+ database: str,
354
+ table: str
357
355
  ) -> None:
358
356
  """
359
357
  Build instance attributes.
360
358
 
361
359
  Parameters
362
360
  ----------
363
- rdatabase : Database or DatabaseConnection instance.
364
- database_name : Database name.
365
- table_name : Table name.
361
+ db: `Database` instance.
362
+ database : Database name.
363
+ table : Table name.
366
364
  """
367
365
 
368
366
  # Set parameter.
369
- self._rdatabase = rdatabase
370
- self._database_name = database_name
371
- self._table_name = table_name
367
+ self.db = db
368
+ self.database = database
369
+ self.table = table
372
370
 
373
371
 
374
372
  def _get_info_attrs(self) -> dict:
@@ -381,20 +379,20 @@ class DatabaseInformationTable(DatabaseInformation):
381
379
  """
382
380
 
383
381
  # Select.
384
- where = '`TABLE_SCHEMA` = :database_name AND `TABLE_NAME` = :table_name'
385
- result = self._rdatabase.execute.select(
382
+ where = '`TABLE_SCHEMA` = :database AND `TABLE_NAME` = :table_'
383
+ result = self.db.execute.select(
386
384
  'information_schema.TABLES',
387
385
  where=where,
388
386
  limit=1,
389
- database_name=self._database_name,
390
- table_name=self._table_name
387
+ database=self.database,
388
+ table_=self.table
391
389
  )
392
390
 
393
391
  # Convert.
394
392
  info_table = result.to_table()
395
393
 
396
394
  ## Check.
397
- assert len(info_table) != 0, "database '%s' or table '%s' not exist" % (self._database_name, self._table_name)
395
+ assert len(info_table) != 0, "database '%s' or table '%s' not exist" % (self.database, self.table)
398
396
 
399
397
  info_attrs = info_table[0]
400
398
 
@@ -411,20 +409,20 @@ class DatabaseInformationTable(DatabaseInformation):
411
409
  """
412
410
 
413
411
  # Select.
414
- where = '`TABLE_SCHEMA` = :database_name AND `TABLE_NAME` = :table_name'
415
- result = self._rdatabase.execute.select(
412
+ where = '`TABLE_SCHEMA` = :database AND `TABLE_NAME` = :table_'
413
+ result = self.db.execute.select(
416
414
  'information_schema.COLUMNS',
417
415
  where=where,
418
416
  order='`ORDINAL_POSITION`',
419
- database_name=self._database_name,
420
- table_name=self._table_name
417
+ database=self.database,
418
+ table_=self.table
421
419
  )
422
420
 
423
421
  # Convert.
424
422
  info_table = result.to_table()
425
423
 
426
424
  ## Check.
427
- assert len(info_table) != 0, "database '%s' or table '%s' not exist" % (self._database_name, self._table_name)
425
+ assert len(info_table) != 0, "database '%s' or table '%s' not exist" % (self.database, self.table)
428
426
 
429
427
  return info_table
430
428
 
@@ -445,27 +443,27 @@ class DatabaseInformationColumn(DatabaseInformation):
445
443
 
446
444
  def __init__(
447
445
  self,
448
- rdatabase: Database | DatabaseConnection,
449
- database_name: str,
450
- table_name: str,
451
- column_name: str
446
+ db: Database,
447
+ database: str,
448
+ table: str,
449
+ column: str
452
450
  ) -> None:
453
451
  """
454
452
  Build instance attributes.
455
453
 
456
454
  Parameters
457
455
  ----------
458
- rdatabase : Database or DatabaseConnection instance.
459
- database_name : Database name.
460
- table_name : Table name.
461
- column_name : Column name.
456
+ db: `Database` instance.
457
+ database : Database name.
458
+ table : Table name.
459
+ column : Column name.
462
460
  """
463
461
 
464
462
  # Set parameter.
465
- self._rdatabase = rdatabase
466
- self._database_name = database_name
467
- self._table_name = table_name
468
- self._column_name = column_name
463
+ self.db = db
464
+ self.database = database
465
+ self.table = table
466
+ self.column = column
469
467
 
470
468
 
471
469
  def _get_info_attrs(self) -> dict:
@@ -478,21 +476,21 @@ class DatabaseInformationColumn(DatabaseInformation):
478
476
  """
479
477
 
480
478
  # Select.
481
- where = '`TABLE_SCHEMA` = :database_name AND `TABLE_NAME` = :table_name AND `COLUMN_NAME` = :column_name'
482
- result = self._rdatabase.execute.select(
479
+ where = '`TABLE_SCHEMA` = :database AND `TABLE_NAME` = :table_ AND `COLUMN_NAME` = :column'
480
+ result = self.db.execute.select(
483
481
  'information_schema.COLUMNS',
484
482
  where=where,
485
483
  limit=1,
486
- database_name=self._database_name,
487
- table_name=self._table_name,
488
- column_name=self._column_name
484
+ database=self.database,
485
+ table_=self.table,
486
+ column=self.column
489
487
  )
490
488
 
491
489
  # Convert.
492
490
  info_table = result.to_table()
493
491
 
494
492
  ## Check.
495
- assert len(info_table) != 0, "database '%s' or table '%s' or column '%s' not exist" % (self._database_name, self._table_name, self._column_name)
493
+ assert len(info_table) != 0, "database '%s' or table '%s' or column '%s' not exist" % (self.database, self.table, self.column)
496
494
 
497
495
  info_attrs = info_table[0]
498
496