Create collection using cosdata client
(name, description=None)
| 46 | |
| 47 | |
| 48 | def create_db(name, description=None): |
| 49 | """Create collection using cosdata client""" |
| 50 | client._ensure_session() |
| 51 | url = f"{client.base_url}/collections" |
| 52 | data = { |
| 53 | "name": name, |
| 54 | "description": description, |
| 55 | "usv_options": {"enabled": True}, |
| 56 | "config": {"max_vectors": None, "replication_factor": None}, |
| 57 | "store_raw_text": False, |
| 58 | } |
| 59 | response = requests.post(url, headers=client._get_headers(), data=json.dumps(data), verify=client.verify_ssl) |
| 60 | if response.status_code not in [200, 201]: |
| 61 | raise Exception(f"Failed to create collection: {response.text}") |
| 62 | |
| 63 | |
| 64 | def create_explicit_index(name): |