|
187 | 187 | "\n",
|
188 | 188 | " def delete_all_query(self):\n",
|
189 | 189 | " return \"TRUNCATE {table_name};\".format(table_name=self._quote_ident(self.table_name))\n",
|
| 190 | + "\n", |
| 191 | + " def drop_table_query(self):\n", |
| 192 | + " return \"DROP TABLE IF EXISTS {table_name};\".format(table_name=self._quote_ident(self.table_name))\n", |
190 | 193 | " \n",
|
191 | 194 | " def create_ivfflat_index_query(self, num_records):\n",
|
192 | 195 | " \"\"\"\n",
|
|
411 | 414 | " query = self.builder.delete_all_query()\n",
|
412 | 415 | " async with await self.connect() as pool:\n",
|
413 | 416 | " await pool.execute(query)\n",
|
| 417 | + " \n", |
| 418 | + " async def drop_table(self):\n", |
| 419 | + " \"\"\"\n", |
| 420 | + " Drops the table\n", |
| 421 | + "\n", |
| 422 | + " Returns:\n", |
| 423 | + " None\n", |
| 424 | + " \"\"\"\n", |
| 425 | + " query = self.builder.drop_table_query()\n", |
| 426 | + " async with await self.connect() as pool:\n", |
| 427 | + " await pool.execute(query)\n", |
414 | 428 | "\n",
|
415 | 429 | " async def _get_approx_count(self):\n",
|
416 | 430 | " \"\"\"\n",
|
|
476 | 490 | "text/markdown": [
|
477 | 491 | "---\n",
|
478 | 492 | "\n",
|
479 |
| - "[source](https://github.com/timescale/python-vector/blob/main/timescale_vector/client.py#L248){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n", |
| 493 | + "[source](https://github.com/timescale/python-vector/blob/main/timescale_vector/client.py#L256){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n", |
480 | 494 | "\n",
|
481 | 495 | "### Async.create_tables\n",
|
482 | 496 | "\n",
|
|
490 | 504 | "text/plain": [
|
491 | 505 | "---\n",
|
492 | 506 | "\n",
|
493 |
| - "[source](https://github.com/timescale/python-vector/blob/main/timescale_vector/client.py#L248){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n", |
| 507 | + "[source](https://github.com/timescale/python-vector/blob/main/timescale_vector/client.py#L256){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n", |
494 | 508 | "\n",
|
495 | 509 | "### Async.create_tables\n",
|
496 | 510 | "\n",
|
|
521 | 535 | "text/markdown": [
|
522 | 536 | "---\n",
|
523 | 537 | "\n",
|
524 |
| - "[source](https://github.com/timescale/python-vector/blob/main/timescale_vector/client.py#L248){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n", |
| 538 | + "[source](https://github.com/timescale/python-vector/blob/main/timescale_vector/client.py#L256){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n", |
525 | 539 | "\n",
|
526 | 540 | "### Async.create_tables\n",
|
527 | 541 | "\n",
|
|
535 | 549 | "text/plain": [
|
536 | 550 | "---\n",
|
537 | 551 | "\n",
|
538 |
| - "[source](https://github.com/timescale/python-vector/blob/main/timescale_vector/client.py#L248){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n", |
| 552 | + "[source](https://github.com/timescale/python-vector/blob/main/timescale_vector/client.py#L256){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n", |
539 | 553 | "\n",
|
540 | 554 | "### Async.create_tables\n",
|
541 | 555 | "\n",
|
|
566 | 580 | "text/markdown": [
|
567 | 581 | "---\n",
|
568 | 582 | "\n",
|
569 |
| - "[source](https://github.com/timescale/python-vector/blob/main/timescale_vector/client.py#L311){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n", |
| 583 | + "[source](https://github.com/timescale/python-vector/blob/main/timescale_vector/client.py#L319){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n", |
570 | 584 | "\n",
|
571 | 585 | "### Async.search\n",
|
572 | 586 | "\n",
|
|
582 | 596 | "text/plain": [
|
583 | 597 | "---\n",
|
584 | 598 | "\n",
|
585 |
| - "[source](https://github.com/timescale/python-vector/blob/main/timescale_vector/client.py#L311){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n", |
| 599 | + "[source](https://github.com/timescale/python-vector/blob/main/timescale_vector/client.py#L319){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n", |
586 | 600 | "\n",
|
587 | 601 | "### Async.search\n",
|
588 | 602 | "\n",
|
|
702 | 716 | "\n",
|
703 | 717 | "\n",
|
704 | 718 | "await vec.delete_all()\n",
|
705 |
| - "assert await vec.table_is_empty()" |
| 719 | + "assert await vec.table_is_empty()\n", |
| 720 | + "\n", |
| 721 | + "await vec.drop_table()" |
706 | 722 | ]
|
707 | 723 | },
|
708 | 724 | {
|
|
865 | 881 | " with conn.cursor() as cur:\n",
|
866 | 882 | " cur.execute(query)\n",
|
867 | 883 | "\n",
|
| 884 | + " def drop_table(self):\n", |
| 885 | + " \"\"\"\n", |
| 886 | + " Drops the table\n", |
| 887 | + "\n", |
| 888 | + " Returns:\n", |
| 889 | + " None\n", |
| 890 | + " \"\"\"\n", |
| 891 | + " query = self.builder.drop_table_query()\n", |
| 892 | + " with self.connect() as conn:\n", |
| 893 | + " with conn.cursor() as cur:\n", |
| 894 | + " cur.execute(query)\n", |
| 895 | + "\n", |
868 | 896 | " def _get_approx_count(self):\n",
|
869 | 897 | " \"\"\"\n",
|
870 | 898 | " Retrieves an approximate count of records in the table.\n",
|
|
938 | 966 | "text/markdown": [
|
939 | 967 | "---\n",
|
940 | 968 | "\n",
|
941 |
| - "[source](https://github.com/timescale/python-vector/blob/main/timescale_vector/client.py#L438){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n", |
| 969 | + "[source](https://github.com/timescale/python-vector/blob/main/timescale_vector/client.py#L446){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n", |
942 | 970 | "\n",
|
943 | 971 | "### Sync.create_tables\n",
|
944 | 972 | "\n",
|
|
952 | 980 | "text/plain": [
|
953 | 981 | "---\n",
|
954 | 982 | "\n",
|
955 |
| - "[source](https://github.com/timescale/python-vector/blob/main/timescale_vector/client.py#L438){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n", |
| 983 | + "[source](https://github.com/timescale/python-vector/blob/main/timescale_vector/client.py#L446){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n", |
956 | 984 | "\n",
|
957 | 985 | "### Sync.create_tables\n",
|
958 | 986 | "\n",
|
|
983 | 1011 | "text/markdown": [
|
984 | 1012 | "---\n",
|
985 | 1013 | "\n",
|
986 |
| - "[source](https://github.com/timescale/python-vector/blob/main/timescale_vector/client.py#L419){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n", |
| 1014 | + "[source](https://github.com/timescale/python-vector/blob/main/timescale_vector/client.py#L427){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n", |
987 | 1015 | "\n",
|
988 | 1016 | "### Sync.upsert\n",
|
989 | 1017 | "\n",
|
|
1000 | 1028 | "text/plain": [
|
1001 | 1029 | "---\n",
|
1002 | 1030 | "\n",
|
1003 |
| - "[source](https://github.com/timescale/python-vector/blob/main/timescale_vector/client.py#L419){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n", |
| 1031 | + "[source](https://github.com/timescale/python-vector/blob/main/timescale_vector/client.py#L427){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n", |
1004 | 1032 | "\n",
|
1005 | 1033 | "### Sync.upsert\n",
|
1006 | 1034 | "\n",
|
|
1034 | 1062 | "text/markdown": [
|
1035 | 1063 | "---\n",
|
1036 | 1064 | "\n",
|
1037 |
| - "[source](https://github.com/timescale/python-vector/blob/main/timescale_vector/client.py#L507){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n", |
| 1065 | + "[source](https://github.com/timescale/python-vector/blob/main/timescale_vector/client.py#L515){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n", |
1038 | 1066 | "\n",
|
1039 | 1067 | "### Sync.search\n",
|
1040 | 1068 | "\n",
|
|
1055 | 1083 | "text/plain": [
|
1056 | 1084 | "---\n",
|
1057 | 1085 | "\n",
|
1058 |
| - "[source](https://github.com/timescale/python-vector/blob/main/timescale_vector/client.py#L507){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n", |
| 1086 | + "[source](https://github.com/timescale/python-vector/blob/main/timescale_vector/client.py#L515){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n", |
1059 | 1087 | "\n",
|
1060 | 1088 | "### Sync.search\n",
|
1061 | 1089 | "\n",
|
|
1187 | 1215 | "assert rec[0][SEARCH_RESULT_DISTANCE_IDX] == 0.0009438353921149556\n",
|
1188 | 1216 | "\n",
|
1189 | 1217 | "vec.delete_all()\n",
|
1190 |
| - "assert vec.table_is_empty()" |
| 1218 | + "assert vec.table_is_empty()\n", |
| 1219 | + "\n", |
| 1220 | + "vec.drop_table()" |
1191 | 1221 | ]
|
1192 | 1222 | },
|
1193 | 1223 | {
|
|
0 commit comments