(self, tablename:str, columns)
| 235 | raise e |
| 236 | |
| 237 | def create_columns(self, tablename:str, columns): |
| 238 | try: |
| 239 | if not self._hashcolumn in columns: |
| 240 | columns.append(self._hashcolumn) |
| 241 | |
| 242 | sentence = f"ALTER TABLE {tablename}\n" |
| 243 | |
| 244 | for index,column in enumerate(columns): |
| 245 | if not self._check_exists_column(tablename, column): |
| 246 | column_type = "TEXT" |
| 247 | if column.lower() == self._hashcolumn: |
| 248 | column_type = "varchar(50)" |
| 249 | |
| 250 | sentence += f"ADD COLUMN \"{column.lower()}\" {column_type}" |
| 251 | sentence+="," |
| 252 | |
| 253 | if sentence.endswith(","): |
| 254 | sentence=sentence[:-1] |
| 255 | if "COLUMN" in sentence: |
| 256 | self._execute(sentence) |
| 257 | if self._hashcolumn in sentence: |
| 258 | self._execute(f"CREATE UNIQUE INDEX IF NOT EXISTS {tablename}_{self._hashcolumn}_idx ON public.{tablename} USING btree ({self._hashcolumn})") |
| 259 | except Exception as e: |
| 260 | raise e |
| 261 | |
| 262 | def _get_insert_sentence(self, tablename, data, columns=None): |
| 263 | if columns is None: |
no test coverage detected