sql_helper_fn.py
SQLDumpHelper
¶
Write a series of export files to export_dir/paper_id.
Includes.. - .my.cnf file to avoid future password prompt - bash script to export data from MySQL database - environment.yml file to export conda environment
Parameters:
Name | Type | Description | Default |
---|---|---|---|
free_tables
|
List[FreeTable]
|
List of FreeTables to export |
required |
paper_id
|
str
|
Paper ID to use for export file names |
required |
docker_id
|
str
|
Docker container ID to export from. Default None |
None
|
spyglass_version
|
str
|
Spyglass version to include in export. Default None |
None
|
Source code in src/spyglass/utils/sql_helper_fn.py
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 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 |
|
write_mysqldump(free_tables, file_suffix='')
¶
Write mysqlmdump.sh script to export data.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
free_tables
|
List[FreeTable]
|
List of FreeTables to export |
required |
file_suffix
|
str
|
Suffix to append to export file names. Default "" |
''
|
Source code in src/spyglass/utils/sql_helper_fn.py
remove_redundant(s)
¶
Remove redundant parentheses from a string.
'((a=b)OR((c=d)AND((e=f))))' -> '(a=b) OR ((c=d) AND (e=f))'
Full solve would require content parsing, this removes duplicates. https://codegolf.stackexchange.com/questions/250596/remove-redundant-parentheses
Source code in src/spyglass/utils/sql_helper_fn.py
bash_escape_sql(s, add_newline=True)
¶
Escape restriction string for bash.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
s
|
str
|
SQL restriction string |
required |
add_newline
|
bool
|
Add newlines for readability around AND & OR. Default True |
True
|