Database
Details on database management can be found here.
Classes to deal with the configuration files.
DataBases
Class to read and get information from db.json file.
This class is used to read the db.json file and get information about the
databases that are available. It has various methods to get different information
and to print the information in the terminal nicely.
Example: >>> # todo
Source code in pgdtools/db/config.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 | |
dbs
property
Return a list of all available databases.
Returns:
| Type | Description |
|---|---|
List[str]
|
List of all available databases as a list of strings. |
DataBase
Class to read and get information from a single database, e.g., sic.
Source code in pgdtools/db/config.py
name
property
Return the name of the database.
version_latest
property
Return the latest version of the database, according to date.
versions
property
Return all versions of the database.
__init__(parent, db)
Initialize the class.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
parent
|
Parent class. |
required | |
db
|
str
|
Name of the database to get. |
required |
Raises:
| Type | Description |
|---|---|
TypeError
|
If the parent class is not of type |
Source code in pgdtools/db/config.py
entry_by_keyword(keyword, value)
Get a given version entry by a keyword and value pair.
Various versions exist in a given database. Selecting a unique keyword and
value, a dictionary of that version entry is returned. Note that if
a keyword, value pair is not unique (e.g., the keyword grains can have
the same value in multiple entries), the first occurrence is returned.
If the value does not exist, an empty dictionary is returned.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
keyword
|
str
|
Dictionary keyword to search for. |
required |
value
|
Any
|
Value of the keyword to search for. |
required |
Returns:
| Type | Description |
|---|---|
dict
|
Dictionary of the entry. |
Source code in pgdtools/db/config.py
__init__()
Initialize the class.
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
If the |
Source code in pgdtools/db/config.py
database(db)
Return a single database.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
db
|
str
|
Name of the database to get, e.g., "sic". |
required |
Returns:
| Type | Description |
|---|---|
DataBase
|
A single database as a |
urls(all=False)
Return a list of URLs for all types of databases.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
all
|
If True, return all URLs for all versions of the database. Otherwise, return the latest databases. |
False
|
Returns:
| Type | Description |
|---|---|
List[str]
|
List of URLs for all databases chosen as a list of strings. |