-
Notifications
You must be signed in to change notification settings - Fork 3k
[Table] Initializing sdk, samples and tests #11987
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from 250 commits
Commits
Show all changes
344 commits
Select commit
Hold shift + click to select a range
872c3a5
running tests
LibbaLawrence 1934a81
fixing nonetype error trial one
LibbaLawrence 54e06a3
fixing models
LibbaLawrence fded937
fixing pylint
LibbaLawrence a049675
trying to redmodel tableservices
LibbaLawrence c951e9d
trying to redmodel tableservices
LibbaLawrence 9c6ef04
attempt to fix NoneType errr
LibbaLawrence 3a9d22b
trying NoneType part 2
LibbaLawrence e94f33c
fixing NoneType
LibbaLawrence 87a7cc4
fixed pylint
LibbaLawrence fb00beb
fixed Nonetype call
LibbaLawrence b4b7a93
all auth forms working correctly :)
LibbaLawrence 8787b78
fixed single quote test
LibbaLawrence 499c719
fixed insert to create
LibbaLawrence a163f5b
got test_table_client working
LibbaLawrence b5b4f6b
passing custom user tests
LibbaLawrence 53fc32d
remvoing encryption changes
LibbaLawrence 5eee947
initializing async clients
LibbaLawrence 6d0ecb7
created __init__ for async TableService and TableClient
LibbaLawrence 65d54d9
creating table client async methods
LibbaLawrence 352b675
list quques working
LibbaLawrence 4e3d51a
assertEqual to assertIn on usercustom tests
LibbaLawrence b6e99e2
assewrtIn for table_client test
LibbaLawrence 6c73647
prelim async service client created
LibbaLawrence 6eb97ff
changed to EntityProperties when deserialized
LibbaLawrence 333476b
made changes (Krista) to SDK
LibbaLawrence 791dbc6
ran service tests
LibbaLawrence cd1ba13
updated design of update and upsert methods
LibbaLawrence b4f53fe
fixed upsert/update
LibbaLawrence 6acf215
reflected change to create_entity
LibbaLawrence afa22af
fixed problems with upsert function
LibbaLawrence 5f88fa6
fixed upsert/update functions on async clients
LibbaLawrence 776baa6
pausing on tests
LibbaLawrence 21db1c6
fixed test failing on HttpResponse
LibbaLawrence 1f6fb8c
fixing 2.7 errorZ
LibbaLawrence f97c6bb
trying to fix 2.7
LibbaLawrence 58312c5
fixed tests
LibbaLawrence ad90b6e
removed problem with unbpund fucntion
LibbaLawrence 8f58a13
track 1 async sdk
LibbaLawrence 41e4c30
renamed aio to _aio
LibbaLawrence fef6a1a
updating comments
LibbaLawrence 661e64e
tweaking comments and types for stub gen
LibbaLawrence 0e153ea
fixed pylint issue
LibbaLawrence be808aa
fixed list_tables to query_tables
LibbaLawrence 07f4a18
pylint errors
LibbaLawrence 7527deb
fixing type errors
LibbaLawrence 172a8d3
updating samples
LibbaLawrence a1a5bb6
fixing comments
LibbaLawrence fb37769
updating README
LibbaLawrence 07481da
fixing PR comments on keyword and credential
LibbaLawrence 685ce54
editing order of docstrings
LibbaLawrence 7aef14c
fixing queue comments
LibbaLawrence a4cc685
fixing queue comments
LibbaLawrence 0da6cb7
delete table has no return response
LibbaLawrence a3232e9
changing types to model types
LibbaLawrence b743848
added keys to dictionary
LibbaLawrence ac2891c
changing types to model types
LibbaLawrence db6d180
fixed stroage reference
LibbaLawrence c59d427
fixing docstring reutrn
LibbaLawrence ed06ec0
fixed cathc and raise same error
LibbaLawrence 9d737a2
UpdateMode in init
LibbaLawrence bb8a47e
obj to _
LibbaLawrence 514d733
fixing comments
LibbaLawrence 8fb7513
fixed metadata return
LibbaLawrence aca49d2
fixed comments
LibbaLawrence 3ce7dd0
fixing test error
LibbaLawrence 8779648
fixed depedncies
LibbaLawrence cedd37d
fixing type
LibbaLawrence 954902a
fixing stubgen error
LibbaLawrence 7987bd0
changed to ivar
LibbaLawrence 73d7c10
fixing type error
LibbaLawrence 4763812
editing samples/ fixing pylint
LibbaLawrence ce5b6b9
reformatted service client sampels
LibbaLawrence cd1fe8e
added more official samples
LibbaLawrence 554c48f
added in teh create and delete table in table client
LibbaLawrence 04571c7
working on client samples
LibbaLawrence 42b71f8
linked README to samples
LibbaLawrence e0f42ba
TODO for return types
LibbaLawrence 482ac07
changed query entity to get entity
LibbaLawrence e4fcf39
edited README
LibbaLawrence 16127fa
made UpdateMode into an enum
LibbaLawrence e7580c0
changed return type of cont token to dict
LibbaLawrence 946965c
fixed readme common uses
LibbaLawrence 2e9abe6
todos created
LibbaLawrence 60420f0
fixed continuation token to a dictionary
LibbaLawrence d8babbd
fixed continuation error
LibbaLawrence cd42322
changed query to individual entries
LibbaLawrence b1d30c5
editing README pr comments
LibbaLawrence ecddf4d
removed AAD from readme
LibbaLawrence 3fe73b0
removed TODO
LibbaLawrence 7e356d6
getting rid of exposed secret
LibbaLawrence e655a5c
added design updates to async client
LibbaLawrence 930532d
stahs
LibbaLawrence daba27c
fixed import
LibbaLawrence a3a80fe
fixed init file
LibbaLawrence 8bdf4da
fixed import
LibbaLawrence 317123b
added todo for table
LibbaLawrence 3710160
added return type
LibbaLawrence 2ef1ae1
editing table client return
LibbaLawrence 47e5e8a
changed table name for table standards (Sean fix)
LibbaLawrence b1a6259
editing sas methods
LibbaLawrence a666f9e
work in progress - fixing pre api review comments
LibbaLawrence da62e6b
updated tests to work with fixes
LibbaLawrence bf52e40
re-running tests for verification'
LibbaLawrence c15672d
fixed small errors with changing method names
LibbaLawrence 80fa9d1
fixed storgae_process_error -> table instead of storage, created meta…
LibbaLawrence 74e860f
made metadata for entities separate from entity itself (see _entity.py)
LibbaLawrence 46dcd22
updated readme and added regex check for table names on TableClient a…
seankane-msft a20532e
oops forgot to import re in the _table_client.py
seankane-msft dc67a98
metadata test passing
LibbaLawrence 28f3fa4
fixed unimported entity
LibbaLawrence b97a649
added user defined filter option with parameters
LibbaLawrence c58032c
added user defined filter option with parameters
LibbaLawrence 59e2408
changed the regex test to match to fit with python2
seankane-msft c1d9e25
fixed linting issues thrown by pylint
seankane-msft 91622db
re-ran test
LibbaLawrence 47c7d4b
updating samples part 1
LibbaLawrence e2e19f6
updating asserts part 2
LibbaLawrence 8f4cc97
removing references to common
LibbaLawrence c7ff4b0
fixing sas on sample
LibbaLawrence 78e9fa5
fixing import statement
LibbaLawrence 500a6e2
attempting to fix dateutil error
LibbaLawrence f546351
trying to fix enum in entity property
LibbaLawrence 31b68ee
fix #2 dateutil
LibbaLawrence e987dcf
attempting to fix dateutil error
LibbaLawrence 30be2be
fixing test import
LibbaLawrence 1f8e970
remove unuse import
LibbaLawrence c3399c0
added tests for table_client and table_service_client
seankane-msft 19f5936
adding live recordings
seankane-msft 9143b9d
Merge branch 'lilaw_table' of https://github.com/LibbaLawrence/azure-…
seankane-msft a799d47
fix #2 dateutil
LibbaLawrence 18a57e7
updated dev_requirements, changed test name
seankane-msft a84bda3
py 2.7 doesnt have timezone - siwtch to UTC
LibbaLawrence 8c79977
reverting back to libbas recordings
seankane-msft bff0099
reverting to using tzutc -- for now
LibbaLawrence 22d6014
updating samples a little with error printing
LibbaLawrence 4e46dca
replicated tzutc class with class Timezone
LibbaLawrence 2b77e60
forgot to create table twice for error
LibbaLawrence 3e04e54
changed regex to fxn in _error.py, added second assertion to tests, u…
seankane-msft af9d329
updating samples to reflect sdk part 1
LibbaLawrence 76b25e3
commented out cryptogrpahy from encryption test
LibbaLawrence adb71c2
removed commented out code and changed the invalid table name
seankane-msft eec3a0c
updating docstrings
LibbaLawrence f53c793
'commented out references to cryptography
LibbaLawrence 44009bf
commented out pylint errors related to encryption
LibbaLawrence 5b24a15
updated delete entity to show etag
LibbaLawrence a6a7442
still finding encryption
LibbaLawrence d5413b0
removed list froma round itempaged
LibbaLawrence a60c5cd
commenting out test
LibbaLawrence 12a5df3
Merge pull request #8 from seankane-msft/clarify-readme
seankane-msft 6b0fbe1
commented out tests
LibbaLawrence 4d5444c
fixed enum on edmtype
LibbaLawrence 2fb43e2
updated update entity
LibbaLawrence 3e25c1b
fixing apiview comments on sas
LibbaLawrence fd536b1
added table name to table clinet
LibbaLawrence 27ac825
changing ItemPaged to ItemPaged[str[
LibbaLawrence 8205d80
changing properties to private
LibbaLawrence 776f85f
changes form apiview archboard pre meeting
LibbaLawrence 9de490a
added filter type
LibbaLawrence 05db919
TODO on from_string in SAS, fixed error in table querying ItemPaged r…
LibbaLawrence 3b48674
changed name to _primary_hostname not primay_hopstname
LibbaLawrence a55d112
oops missed the other hostname
LibbaLawrence d13d9a5
oops missed the other other hostname
LibbaLawrence c7767cc
added a client base for tableclient and tableserviceclient, passes al…
seankane-msft 5fab19c
fixed TODO on sas
LibbaLawrence 24e640d
changes to satisfy linter
seankane-msft cdeb4a4
tweaking delete
LibbaLawrence 0824c5d
moved account parsing to the base class, fixed more linting issues
seankane-msft 5b57238
resolved comments
seankane-msft 7c6640f
Merge pull request #9 from seankane-msft/base-table-client
seankane-msft 9f47e1d
Merge branch 'lilaw_async' of https://github.com/LibbaLawrence/azure-…
seankane-msft 4737ff6
updating samples
LibbaLawrence 0966566
updating updatemode
LibbaLawrence 8ac26b6
updating UpdateMode
LibbaLawrence 80cbe26
Merge branch 'lilaw_table' of https://github.com/LibbaLawrence/azure-…
LibbaLawrence c8d2333
importing typing for union
LibbaLawrence 430c699
initial commit for diff
seankane-msft f6802aa
Merge branch 'lilaw_table' of https://github.com/LibbaLawrence/azure-…
seankane-msft eb6f3f6
change to REPLACE'
LibbaLawrence 7eabb9f
initial commit for pulling down current async status, ran a tests liv…
seankane-msft 871788a
renamed entity tableentity
LibbaLawrence 063abd2
allowed select to be array or str
LibbaLawrence 85be966
made Table class
LibbaLawrence 2b68bfb
renamed a new directory for azure-data-tables
LibbaLawrence 7e72cd0
removing storgae reference
LibbaLawrence da032fc
changed query 'r' to read
LibbaLawrence bbf2df2
removing some commented out code
LibbaLawrence 60f78f8
updating delete/create table comments
LibbaLawrence 47f49c4
docstring return type for table
LibbaLawrence c3faee2
bullet point auth
LibbaLawrence 5b2f443
base work for async models, working on passing last few tests, added …
seankane-msft 7ed02cc
removing packages to exclude
LibbaLawrence e155515
fixing README
LibbaLawrence bf58264
adding to the blurb in the readme from the archboard pwpt
LibbaLawrence 3b5f476
passing most async tests, issues with list_tables query_options curre…
seankane-msft 2fe0a1b
fixing blank line
LibbaLawrence dff2bf7
making nspkg for data
LibbaLawrence 9fd2098
removed async
LibbaLawrence 674606a
changed to relative imports
LibbaLawrence 12fd8de
:had to update naming
LibbaLawrence 724c24d
stahs
LibbaLawrence 9ebfd71
stahs
LibbaLawrence 6cffbd0
had to fix list and query tables
LibbaLawrence 6b16cdb
build mad about version
LibbaLawrence aec8585
changed version to match 1.0.0
LibbaLawrence ebc2d77
changed how results_per_page is passed in, need to verify with Libba …
seankane-msft 32dbb11
forgot and init file - path was being skipped in build
LibbaLawrence 72be007
changing list and query to align with new api view
seankane-msft 728a4bd
passing the list_tables_with_num_results again
seankane-msft 59a44f7
passes tests when run locally, does not pass in live-mode. the behavi…
seankane-msft 49867a9
fixed test back
LibbaLawrence 4327be0
hand to change query to list tables
LibbaLawrence 841cbdd
temp fix on README error
LibbaLawrence db7246e
had to change msrest version
LibbaLawrence 874dcb5
fixing pylint error
LibbaLawrence e6442f3
fixed all merge conflicts
seankane-msft ef06a44
Update README.md
LibbaLawrence 12736e6
fixing more merge commits
seankane-msft de68693
ignorning nspkg readme
LibbaLawrence a3eeee4
Merge branch 'lilaw_table' of https://github.com/LibbaLawrence/azure-…
LibbaLawrence c9f36de
addressed Libbas comments
seankane-msft 320a228
regenerated code
LibbaLawrence e95ea30
fixed Krista comments on readmes
LibbaLawrence 086275c
fixing Krista comments
LibbaLawrence 582fb26
fixed anna's changes
LibbaLawrence 303a400
addressed all of izzys comments
seankane-msft 3b64fa4
reran all tests and fixed a few bugs from pulling down
seankane-msft 0f35848
removing unsued import
LibbaLawrence cf5db63
Merge pull request #10 from seankane-msft/async-tables-sean
LibbaLawrence aaf308e
fixing merge errors
LibbaLawrence 5a4f784
fixing docstrings
LibbaLawrence 0928b2a
fixewd docstring
LibbaLawrence 70f564a
fixing docstrings
LibbaLawrence 88f469b
fixing docs
LibbaLawrence 8e5d2f7
verifying tests work:
LibbaLawrence 0ec9e74
verifying tests'
LibbaLawrence a2dc16a
fixed sync for parameters
LibbaLawrence 8f20ef8
fixed async clients parameters
LibbaLawrence 83e0803
fixing error for mode
LibbaLawrence 52293ac
fixing pylint errors
LibbaLawrence e0ff5fe
re running tests
LibbaLawrence 95520f4
added more tests
LibbaLawrence 56bec1e
fixing models for tests
LibbaLawrence 5347710
fixed init
LibbaLawrence 2b39a4f
had to fix fomratting of async docstring types
LibbaLawrence 1ec8bcc
Merge pull request #11 from Azure/master
LibbaLawrence ea205b6
Merge branch 'lilaw_table' into master
LibbaLawrence 9e2c8fa
Merge pull request #12 from LibbaLawrence/master
LibbaLawrence 017bc37
removing json files and fixing merge conflict
LibbaLawrence 41d287d
checking if revert fixed the build
LibbaLawrence File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
include *.md | ||
include azure/__init__.py | ||
include azure/data/__init__.py |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Microsoft Azure Data SDK for Python | ||
|
||
This is the Microsoft Azure Data namespace package. | ||
|
||
This package is not intended to be installed directly by the end user. | ||
|
||
It provides the necessary files for other packages to extend the | ||
azure.storage namespace. | ||
|
||
If you are looking to install the Azure Data libraries, see the | ||
[azure](https://pypi.python.org/pypi/azure) bundle package. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
__path__ = __import__('pkgutil').extend_path(__path__, __name__) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
__path__ = __import__('pkgutil').extend_path(__path__, __name__) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[bdist_wheel] | ||
universal=1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#!/usr/bin/env python | ||
|
||
# ------------------------------------------------------------------------- | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. See License.txt in the project root for | ||
# license information. | ||
# -------------------------------------------------------------------------- | ||
|
||
from setuptools import setup | ||
|
||
# azure v0.x is not compatible with this package | ||
# azure v0.x used to have a __version__ attribute (newer versions don't) | ||
try: | ||
import azure | ||
|
||
try: | ||
ver = azure.__version__ | ||
raise Exception( | ||
'This package is incompatible with azure=={}. '.format(ver) + | ||
'Uninstall it with "pip uninstall azure".' | ||
) | ||
except AttributeError: | ||
pass | ||
except ImportError: | ||
pass | ||
|
||
LibbaLawrence marked this conversation as resolved.
Show resolved
Hide resolved
|
||
setup( | ||
name='azure-data-nspkg', | ||
version='1.0.0', | ||
description='Microsoft Azure Data Namespace Package [Internal]', | ||
long_description=open('README.md', 'r').read(), | ||
license='MIT License', | ||
author='Microsoft Corporation', | ||
author_email='[email protected]', | ||
url='https://github.com/Azure/azure-data-python', | ||
classifiers=[ | ||
'Development Status :: 5 - Production/Stable', | ||
'Programming Language :: Python', | ||
'Programming Language :: Python :: 2', | ||
'Programming Language :: Python :: 2.7', | ||
'Programming Language :: Python :: 3', | ||
'Programming Language :: Python :: 3.3', | ||
'Programming Language :: Python :: 3.4', | ||
LibbaLawrence marked this conversation as resolved.
Show resolved
Hide resolved
|
||
'Programming Language :: Python :: 3.5', | ||
'Programming Language :: Python :: 3.6', | ||
'Programming Language :: Python :: 3.7', | ||
'License :: OSI Approved :: MIT License', | ||
], | ||
zip_safe=False, | ||
packages=[ | ||
'azure.data', | ||
], | ||
install_requires=[ | ||
'azure-nspkg>=1.0.0', | ||
LibbaLawrence marked this conversation as resolved.
Show resolved
Hide resolved
|
||
] | ||
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# Change Log azure-table | ||
|
||
## 12.0.0b1 (Unreleased) | ||
|
||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
include *.md | ||
include azure/__init__.py | ||
include LICENSE.txt | ||
recursive-include tests *.py | ||
recursive-include samples *.py *.md |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,297 @@ | ||
# Azure Data Tables client library for Python | ||
|
||
Azure Data Tables is a NoSQL data storing service that can be accessed from anywhere in the world via authenticated calls using HTTP or HTTPS. | ||
Tables scale as needed to support the amount of data inserted, and allow for the storing of data with non-complex accessing. | ||
The Azure Data Tables client can be used to access Azure Storage or Cosmos Storage accounts. | ||
|
||
Common uses of Azure Data Tables include: | ||
|
||
* Storing structured data in the form of tables | ||
* Quickly querying data using a clustered index | ||
|
||
[Source code](https://github.com/Azure/azure-sdk-for-python/tree/master/sdk/table/azure-table/azure/table) | [Package (PyPI)](https://pypi.org/project/azure-table/) | [API reference documentation](https://aka.ms/azsdk/python/table/docs) | [Product documentation](https://docs.microsoft.com/azure/storage/) | [Samples](https://github.com/Azure/azure-sdk-for-python/tree/master/sdk/table/azure-table/samples) | ||
LibbaLawrence marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
## Getting started | ||
|
||
### Prerequisites | ||
* Python 2.7, or 3.5 or later is required to use this package. | ||
* You must have an [Azure subscription](https://azure.microsoft.com/free/) and an | ||
[Azure storage account](https://docs.microsoft.com/azure/storage/common/storage-account-overview) to use this package | ||
or you must have a [Azure Cosmos Account](https://docs.microsoft.com/en-us/azure/cosmos-db/account-overview). | ||
|
||
### Install the package | ||
Install the Azure Data Tables client library for Python with [pip](https://pypi.org/project/pip/): | ||
|
||
```bash | ||
pip install --pre azure-data-tables | ||
``` | ||
|
||
### Create a storage account | ||
If you wish to create a new storage account, you can use the | ||
[Azure Portal](https://docs.microsoft.com/azure/storage/common/storage-quickstart-create-account?tabs=azure-portal), | ||
[Azure PowerShell](https://docs.microsoft.com/azure/storage/common/storage-quickstart-create-account?tabs=azure-powershell), | ||
or [Azure CLI](https://docs.microsoft.com/azure/storage/common/storage-quickstart-create-account?tabs=azure-cli): | ||
|
||
```bash | ||
# Create a new resource group to hold the storage account - | ||
# if using an existing resource group, skip this step | ||
az group create --name MyResourceGroup --location westus2 | ||
|
||
# Create the storage account | ||
az storage account create -n mystorageaccount -g MyResourceGroup | ||
``` | ||
|
||
### Create the client | ||
The Azure Data Tables client library for Python allows you to interact with two types of resources: the storage | ||
account and tables, and entities. Interaction with these resources starts with an instance of a [client](#clients). | ||
To create a client object, you will need the storage account's table service endpoint URL and a credential that allows | ||
you to access the storage account: | ||
|
||
```python | ||
from azure.data.tables import TableServiceClient | ||
|
||
service = TableServiceClient(account_url="https://<mystorageaccount>.table.core.windows.net/", credential=credential) | ||
``` | ||
|
||
#### Looking up the account URL | ||
You can find the storage account's table service URL using the | ||
[Azure Portal](https://docs.microsoft.com/azure/storage/common/storage-account-overview#storage-account-endpoints), | ||
[Azure PowerShell](https://docs.microsoft.com/powershell/module/az.storage/get-azstorageaccount), | ||
or [Azure CLI](https://docs.microsoft.com/cli/azure/storage/account?view=azure-cli-latest#az-storage-account-show): | ||
|
||
```bash | ||
# Get the table service URL for the storage account | ||
az storage account show -n mystorageaccount -g MyResourceGroup --query "primaryEndpoints.table" | ||
``` | ||
|
||
#### Types of credentials | ||
The `credential` parameter may be provided in a number of different forms, depending on the type of | ||
[authorization](https://docs.microsoft.com/azure/storage/common/storage-auth) you wish to use: | ||
1. To use a [shared access signature (SAS) token](https://docs.microsoft.com/azure/storage/common/storage-sas-overview), | ||
provide the token as a string. If your account URL includes the SAS token, omit the credential parameter. | ||
You can generate a SAS token from the Azure Portal under "Shared access signature" or use one of the `generate_sas()` | ||
functions to create a sas token for the storage account or queue: | ||
|
||
```python | ||
from datetime import datetime, timedelta | ||
from azure.data.tables import TableServiceClient, generate_account_sas, ResourceTypes, AccountSasPermissions | ||
|
||
sas_token = generate_account_sas( | ||
account_name="<storage-account-name>", | ||
account_key="<account-access-key>", | ||
resource_types=ResourceTypes(service=True), | ||
permission=AccountSasPermissions(read=True), | ||
expiry=datetime.utcnow() + timedelta(hours=1) | ||
) | ||
|
||
table_service_client = TableServiceClient(account_url="https://<my_account_name>.table.core.windows.net", credential=sas_token) | ||
``` | ||
|
||
2. To use a storage account [shared key](https://docs.microsoft.com/rest/api/storageservices/authenticate-with-shared-key/) | ||
(aka account key or access key), provide the key as a string. This can be found in the Azure Portal under the "Access Keys" | ||
section or by running the following Azure CLI command: | ||
|
||
```az storage account keys list -g MyResourceGroup -n mystorageaccount``` | ||
|
||
Use the key as the credential parameter to authenticate the client: | ||
```python | ||
from azure.data.tables import TableServiceClient | ||
service = TableServiceClient(account_url="https://<my_account_name>.table.core.windows.net", credential="<account_access_key>") | ||
``` | ||
|
||
#### Creating the client from a connection string | ||
Depending on your use case and authorization method, you may prefer to initialize a client instance with a storage | ||
connection string instead of providing the account URL and credential separately. To do this, pass the storage | ||
connection string to the client's `from_connection_string` class method: | ||
|
||
```python | ||
from azure.data.tables import TableServiceClient | ||
|
||
connection_string = "DefaultEndpointsProtocol=https;AccountName=xxxx;AccountKey=xxxx;EndpointSuffix=core.windows.net" | ||
service = TableServiceClient.from_connection_string(conn_str=connection_string) | ||
``` | ||
|
||
The connection string to your storage account can be found in the Azure Portal under the "Access Keys" section or by running the following CLI command: | ||
|
||
```bash | ||
az storage account show-connection-string -g MyResourceGroup -n mystorageaccount | ||
``` | ||
|
||
## Key concepts | ||
The following components make up the Azure Data Tables Service: | ||
* The storage account | ||
* A table within the storage account, which contains a set of entities | ||
* An entity within a table, as a dictionary | ||
|
||
The Azure Data Tables client library for Python allows you to interact with each of these components through the | ||
use of a dedicated client object. | ||
|
||
### Clients | ||
Two different clients are provided to to interact with the various components of the Table Service: | ||
1. [TableServiceClient](https://aka.ms/azsdk/python/table/docs) - | ||
this client represents interaction with the Azure storage account itself, and allows you to acquire preconfigured | ||
client instances to access the tables within. It provides operations to retrieve and configure the account | ||
properties as well as query, create, and delete tables within the account. To perform operations on a specific table, | ||
retrieve a client using the `get_table_client` method. | ||
2. [TableClient](https://aka.ms/azsdk/python/table/docs) - | ||
this client represents interaction with a specific table (which need not exist yet). It provides operations to | ||
create, delete, or update a table and includes operations to query, get, and upsert entities | ||
within it. | ||
|
||
### Entities | ||
* **Create** - Adds an entity to the table. | ||
* **Delete** - Deletes an entity from the table. | ||
* **Update** - Updates an entities information by either merging or replacing the existing entity. | ||
* **Query** - Queries existing entities in a table based off of the QueryOptions (OData). | ||
* **Get** - Gets a specific entity from a table by partition and row key. | ||
* **Upsert** - Merges or replaces an entity in a table, or if the entity does not exist, inserts the entity. | ||
|
||
## Examples | ||
|
||
The following sections provide several code snippets covering some of the most common Table tasks, including: | ||
|
||
* [Creating a table](#creating-a-table "Creating a table") | ||
* [Creating entities](#creating-entities "Creating entities") | ||
* [Querying entities](#querying-entities "Querying entities") | ||
|
||
|
||
### Creating a table | ||
Create a table in your storage account | ||
|
||
```python | ||
from azure.data.tables import TableServiceClient | ||
|
||
table_service_client = TableServiceClient.from_connection_string(conn_str="<connection_string>") | ||
table_service_client.create_table(table_name="myTable") | ||
``` | ||
|
||
### Creating entities | ||
Create entities in the table | ||
|
||
```python | ||
from azure.data.tables import TableClient | ||
|
||
my_entity = {'PartitionKey':'part','RowKey':'row'} | ||
|
||
table_client = TableClient.from_connection_string(conn_str="<connection_string>", table_name="myTable") | ||
entity = table_client.create_entity(entity=my_entity) | ||
``` | ||
|
||
### Querying entities | ||
Querying entities in the table | ||
|
||
```python | ||
from azure.data.tables import TableClient | ||
|
||
my_filter = "text eq Marker" | ||
|
||
table_client = TableClient.from_connection_string(conn_str="<connection_string>", table_name="mytable") | ||
entity = table_client.query_entities(filter=my_filter) | ||
``` | ||
|
||
## Optional Configuration | ||
|
||
Optional keyword arguments can be passed in at the client and per-operation level. The azure-core [reference documentation](https://azuresdkdocs.blob.core.windows.net/$web/python/azure-core/latest/azure.core.html) describes available configurations for retries, logging, transport protocols, and more. | ||
|
||
|
||
### Retry Policy configuration | ||
|
||
Use the following keyword arguments when instantiating a client to configure the retry policy: | ||
|
||
* __retry_total__ (int): Total number of retries to allow. Takes precedence over other counts. | ||
Pass in `retry_total=0` if you do not want to retry on requests. Defaults to 10. | ||
* __retry_connect__ (int): How many connection-related errors to retry on. Defaults to 3. | ||
* __retry_read__ (int): How many times to retry on read errors. Defaults to 3. | ||
* __retry_status__ (int): How many times to retry on bad status codes. Defaults to 3. | ||
* __retry_to_secondary__ (bool): Whether the request should be retried to secondary, if able. | ||
This should only be enabled of RA-GRS accounts are used and potentially stale data can be handled. | ||
Defaults to `False`. | ||
|
||
### Other client / per-operation configuration | ||
|
||
Other optional configuration keyword arguments that can be specified on the client or per-operation. | ||
|
||
**Client keyword arguments:** | ||
|
||
* __connection_timeout__ (int): Optionally sets the connect and read timeout value, in seconds. | ||
* __transport__ (Any): User-provided transport to send the HTTP request. | ||
|
||
**Per-operation keyword arguments:** | ||
|
||
* __raw_response_hook__ (callable): The given callback uses the response returned from the service. | ||
* __raw_request_hook__ (callable): The given callback uses the request before being sent to service. | ||
* __client_request_id__ (str): Optional user specified identification of the request. | ||
* __user_agent__ (str): Appends the custom value to the user-agent header to be sent with the request. | ||
* __logging_enable__ (bool): Enables logging at the DEBUG level. Defaults to False. Can also be passed in at | ||
the client level to enable it for all requests. | ||
* __headers__ (dict): Pass in custom headers as key, value pairs. E.g. `headers={'CustomValue': value}` | ||
|
||
|
||
## Troubleshooting | ||
### General | ||
Azure Data Tables clients raise exceptions defined in [Azure Core](https://github.com/Azure/azure-sdk-for-python/blob/master/sdk/core/azure-core/README.md). | ||
All Table service operations will throw a `HttpResponseError` on failure with helpful [error codes](https://docs.microsoft.com/en-us/rest/api/storageservices/table-service-error-codes). | ||
|
||
### Logging | ||
This library uses the standard | ||
[logging](https://docs.python.org/3/library/logging.html) library for logging. | ||
Basic information about HTTP sessions (URLs, headers, etc.) is logged at INFO | ||
level. | ||
|
||
Detailed DEBUG level logging, including request/response bodies and unredacted | ||
headers, can be enabled on a client with the `logging_enable` argument: | ||
```python | ||
import sys | ||
import logging | ||
from azure.data.tables import TableServiceClient | ||
|
||
# Create a logger for the 'azure.data.tables' SDK | ||
logger = logging.getLogger('azure.data.tables') | ||
logger.setLevel(logging.DEBUG) | ||
|
||
# Configure a console output | ||
handler = logging.StreamHandler(stream=sys.stdout) | ||
logger.addHandler(handler) | ||
|
||
# This client will log detailed information about its HTTP sessions, at DEBUG level | ||
service_client = TableServiceClient.from_connection_string("your_connection_string", logging_enable=True) | ||
``` | ||
|
||
Similarly, `logging_enable` can enable detailed logging for a single operation, | ||
even when it isn't enabled for the client: | ||
```py | ||
service_client.get_service_stats(logging_enable=True) | ||
``` | ||
|
||
## Next steps | ||
|
||
Get started with our [Table samples](https://github.com/Azure/azure-sdk-for-python/tree/master/sdk/table/azure-table/samples). | ||
|
||
Several Azure Data Tables Python SDK samples are available to you in the SDK's GitHub repository. These samples provide example code for additional scenarios commonly encountered while working with Tables: | ||
|
||
* [table_samples_authentication.py](https://github.com/Azure/azure-sdk-for-python/tree/master/sdk/table/azure-table/samples/table_samples_authentication.py) - Examples found in this article: | ||
* From a connection string | ||
* From a shared access key | ||
* From a shared access signature token | ||
* [table_samples_service.py](https://github.com/Azure/azure-sdk-for-python/tree/master/sdk/table/azure-table/samples/table_samples_service.py) - Examples found in this article: | ||
* Get and set service properties | ||
* List tables in a storage account | ||
* Create and delete a table from the service | ||
* Get the TableClient | ||
* [table_samples_client.py](https://github.com/Azure/azure-sdk-for-python/tree/master/sdk/table/azure-table/samples/table_samples_client.py) - Examples found in this article: | ||
* Client creation | ||
* Create a table | ||
* Create and Delete entities | ||
* Query entities | ||
* Update entities | ||
* Upsert entities | ||
|
||
### Additional documentation | ||
For more extensive documentation on Azure Data Tables, see the [Azure Data Tables documentation](https://docs.microsoft.com/azure/storage/tables/) on docs.microsoft.com. | ||
|
||
## Contributing | ||
This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.microsoft.com. | ||
|
||
When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA. | ||
|
||
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [[email protected]](mailto:[email protected]) with any additional questions or comments. |
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.