[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill-6ea8d93c-d80b-45d6-9b56-8d28fda9d12f":3,"$ftgS-q9Isr8GGvZQ2CkpCPysXryJYyVydrWDLz8vJWYU":42},{"id":4,"title":5,"description":6,"categoryId":7,"moduleId":8,"tags":9,"prompt":10,"icon":11,"source":12,"sourceUrl":13,"authorId":14,"authorName":15,"isPublic":16,"stars":17,"runs":18,"createdAt":19,"updatedAt":19,"module":20,"category":27,"packages":33},"6ea8d93c-d80b-45d6-9b56-8d28fda9d12f","azure-data-tables-py","Azure Tables SDK for Python（存储和Cosmos DB）。用于NoSQL键值存储、实体CRUD和批量操作。","cat_coding_backend","mod_coding","sickn33,coding","---\nname: azure-data-tables-py\ndescription: Azure Tables SDK for Python (Storage and Cosmos DB). Use for NoSQL key-value storage, entity CRUD, and batch operations.\nrisk: unknown\nsource: community\ndate_added: '2026-02-27'\n---\n\n# Azure Tables SDK for Python\n\nNoSQL key-value store for structured data (Azure Storage Tables or Cosmos DB Table API).\n\n## Installation\n\n```bash\npip install azure-data-tables azure-identity\n```\n\n## Environment Variables\n\n```bash\n# Azure Storage Tables\nAZURE_STORAGE_ACCOUNT_URL=https:\u002F\u002F\u003Caccount>.table.core.windows.net\n\n# Cosmos DB Table API\nCOSMOS_TABLE_ENDPOINT=https:\u002F\u002F\u003Caccount>.table.cosmos.azure.com\n```\n\n## Authentication\n\n```python\nfrom azure.identity import DefaultAzureCredential\nfrom azure.data.tables import TableServiceClient, TableClient\n\ncredential = DefaultAzureCredential()\nendpoint = \"https:\u002F\u002F\u003Caccount>.table.core.windows.net\"\n\n# Service client (manage tables)\nservice_client = TableServiceClient(endpoint=endpoint, credential=credential)\n\n# Table client (work with entities)\ntable_client = TableClient(endpoint=endpoint, table_name=\"mytable\", credential=credential)\n```\n\n## Client Types\n\n| Client | Purpose |\n|--------|---------|\n| `TableServiceClient` | Create\u002Fdelete tables, list tables |\n| `TableClient` | Entity CRUD, queries |\n\n## Table Operations\n\n```python\n# Create table\nservice_client.create_table(\"mytable\")\n\n# Create if not exists\nservice_client.create_table_if_not_exists(\"mytable\")\n\n# Delete table\nservice_client.delete_table(\"mytable\")\n\n# List tables\nfor table in service_client.list_tables():\n    print(table.name)\n\n# Get table client\ntable_client = service_client.get_table_client(\"mytable\")\n```\n\n## Entity Operations\n\n**Important**: Every entity requires `PartitionKey` and `RowKey` (together form unique ID).\n\n### Create Entity\n\n```python\nentity = {\n    \"PartitionKey\": \"sales\",\n    \"RowKey\": \"order-001\",\n    \"product\": \"Widget\",\n    \"quantity\": 5,\n    \"price\": 9.99,\n    \"shipped\": False\n}\n\n# Create (fails if exists)\ntable_client.create_entity(entity=entity)\n\n# Upsert (create or replace)\ntable_client.upsert_entity(entity=entity)\n```\n\n### Get Entity\n\n```python\n# Get by key (fastest)\nentity = table_client.get_entity(\n    partition_key=\"sales\",\n    row_key=\"order-001\"\n)\nprint(f\"Product: {entity['product']}\")\n```\n\n### Update Entity\n\n```python\n# Replace entire entity\nentity[\"quantity\"] = 10\ntable_client.update_entity(entity=entity, mode=\"replace\")\n\n# Merge (update specific fields only)\nupdate = {\n    \"PartitionKey\": \"sales\",\n    \"RowKey\": \"order-001\",\n    \"shipped\": True\n}\ntable_client.update_entity(entity=update, mode=\"merge\")\n```\n\n### Delete Entity\n\n```python\ntable_client.delete_entity(\n    partition_key=\"sales\",\n    row_key=\"order-001\"\n)\n```\n\n## Query Entities\n\n### Query Within Partition\n\n```python\n# Query by partition (efficient)\nentities = table_client.query_entities(\n    query_filter=\"PartitionKey eq 'sales'\"\n)\nfor entity in entities:\n    print(entity)\n```\n\n### Query with Filters\n\n```python\n# Filter by properties\nentities = table_client.query_entities(\n    query_filter=\"PartitionKey eq 'sales' and quantity gt 3\"\n)\n\n# With parameters (safer)\nentities = table_client.query_entities(\n    query_filter=\"PartitionKey eq @pk and price lt @max_price\",\n    parameters={\"pk\": \"sales\", \"max_price\": 50.0}\n)\n```\n\n### Select Specific Properties\n\n```python\nentities = table_client.query_entities(\n    query_filter=\"PartitionKey eq 'sales'\",\n    select=[\"RowKey\", \"product\", \"price\"]\n)\n```\n\n### List All Entities\n\n```python\n# List all (cross-partition - use sparingly)\nfor entity in table_client.list_entities():\n    print(entity)\n```\n\n## Batch Operations\n\n```python\nfrom azure.data.tables import TableTransactionError\n\n# Batch operations (same partition only!)\noperations = [\n    (\"create\", {\"PartitionKey\": \"batch\", \"RowKey\": \"1\", \"data\": \"first\"}),\n    (\"create\", {\"PartitionKey\": \"batch\", \"RowKey\": \"2\", \"data\": \"second\"}),\n    (\"upsert\", {\"PartitionKey\": \"batch\", \"RowKey\": \"3\", \"data\": \"third\"}),\n]\n\ntry:\n    table_client.submit_transaction(operations)\nexcept TableTransactionError as e:\n    print(f\"Transaction failed: {e}\")\n```\n\n## Async Client\n\n```python\nfrom azure.data.tables.aio import TableServiceClient, TableClient\nfrom azure.identity.aio import DefaultAzureCredential\n\nasync def table_operations():\n    credential = DefaultAzureCredential()\n    \n    async with TableClient(\n        endpoint=\"https:\u002F\u002F\u003Caccount>.table.core.windows.net\",\n        table_name=\"mytable\",\n        credential=credential\n    ) as client:\n        # Create\n        await client.create_entity(entity={\n            \"PartitionKey\": \"async\",\n            \"RowKey\": \"1\",\n            \"data\": \"test\"\n        })\n        \n        # Query\n        async for entity in client.query_entities(\"PartitionKey eq 'async'\"):\n            print(entity)\n\nimport asyncio\nasyncio.run(table_operations())\n```\n\n## Data Types\n\n| Python Type | Table Storage Type |\n|-------------|-------------------|\n| `str` | String |\n| `int` | Int64 |\n| `float` | Double |\n| `bool` | Boolean |\n| `datetime` | DateTime |\n| `bytes` | Binary |\n| `UUID` | Guid |\n\n## Best Practices\n\n1. **Design partition keys** for query patterns and even distribution\n2. **Query within partitions** whenever possible (cross-partition is expensive)\n3. **Use batch operations** for multiple entities in same partition\n4. **Use `upsert_entity`** for idempotent writes\n5. **Use parameterized queries** to prevent injection\n6. **Keep entities small** — max 1MB per entity\n7. **Use async client** for high-throughput scenarios\n\n## When to Use\nThis skill is applicable to execute the workflow or actions described in the overview.\n\n## Limitations\n- Use this skill only when the task clearly matches the scope described above.\n- Do not treat the output as a substitute for environment-specific validation, testing, or expert review.\n- Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.\n","","imported","https:\u002F\u002Fgithub.com\u002Fsickn33\u002Fantigravity-awesome-skills","user_system_seed","SkillOPIC",true,106,1927,"2026-05-16 13:06:12",{"id":8,"name":21,"slug":22,"icon":23,"description":24,"sort":25,"createdAt":26},"编程开发","coding","mdi-code-braces","代码生成、调试、审查，提升开发效率",2,"2026-05-16 12:53:40",{"id":7,"name":28,"slug":29,"icon":30,"description":31,"moduleId":8,"sort":25,"skillCount":32,"createdAt":26},"后端开发","backend","mdi-server","API、数据库、服务端架构",296,[34],{"id":35,"skillId":4,"version":36,"fileName":37,"fileSize":38,"filePath":39,"fileHash":40,"manifest":41,"createdAt":19},"416a31a1-4757-4337-bd1b-d22408f329be","1.0.0","azure-data-tables-py.zip",2264,"uploads\u002Fskills\u002F6ea8d93c-d80b-45d6-9b56-8d28fda9d12f\u002Fazure-data-tables-py.zip","43262d374470bd99396ca5a2e6530d30938ef9d98d1d18437badfee3e903f3d8","[{\"path\":\"SKILL.md\",\"isDirectory\":false,\"size\":5948}]",{"code":43,"message":44,"data":45},200,"success",{"items":46,"stats":47,"page":50},[],{"averageRating":48,"totalRatings":48,"ratingCounts":49},0,[48,48,48,48,48],{"limit":51,"offset":48,"hasMore":52,"nextOffset":51,"ratedOnly":16},15,false]