Skip to content

Commit 9f86899

Browse files
simorenohannatischgahl-levytjprescott
authored andcommitted
[Cosmos] update from_connection_string method (Azure#22536)
* initial commit * Client Constructor (Azure#20310) * Removed some stuff * Looking at constructors * Updated request * Added client close * working client creation Co-authored-by: simorenoh <[email protected]> * read database database read works, but ignored exception is returned: Fatal error on SSL transport NoneType has no attribute 'send' (_loop._proactor.send) RuntimeError: Event loop is closed Unclosed connector/ connection * Update simon_testfile.py * with coroutine Added methods needed to use async with when initializing client, but logs output "Exception ignored... Runtime Error: Event loop is closed" * Update simon_testfile.py * small changes * async with returns no exceptions * async read container * async item read * cleaning up * create item/ database methods * item delete working * docs replace functionality missing upsert and other resources * upsert functionality missing read_all_items and both query methods for container class * missing query methods * CRUD for udf, sproc, triggers * initial query logic + container methods * missing some execution logic and tests * oops * fully working queries * small fix to query_items() also fixed README and added examples_async * Update _cosmos_client_connection_async.py * Update _cosmos_client_connection.py * documentation update * updated MIT dates and get_user_client() description * Update CHANGELOG.md * Delete simon_testfile.py * leftover retry utility * Update README.md * docs and removed six package * changes based on comments still missing discussion resolution on SSL verification and tests for async functionality under test module (apart from samples which are basically end to end tests) * small change in type hints * updated readme * fixes based on conversations * added missing type comments * update changelog for ci pipeline * added typehints, moved params into keywords, added decorators, made _connection_policy private * changes based on sync with central sdk * remove is_system_key from scripts (only used in execute_sproc) is_system_key verifies that an empty partition key is properly dealt with if ['partitionKey']['systemKey'] exists in the container options - however, we do not allow containers to be created with empty partition key values in the python sdk, so the functionality is needless * Revert "remove is_system_key from scripts (only used in execute_sproc)" Reverting last commit, will find way to init is_system_key for now * async script proxy using composition * pylint * capitalized constants * Apply suggestions from code review Clarifying comments for README Co-authored-by: Gahl Levy <[email protected]> * closing python code snippet * last doc updates * Update sdk/cosmos/azure-cosmos/CHANGELOG.md Co-authored-by: Simon Moreno <[email protected]> * version update * cosmos updates for release * fix connection string comma * Update CHANGELOG.md Co-authored-by: annatisch <[email protected]> Co-authored-by: Gahl Levy <[email protected]> Co-authored-by: Travis Prescott <[email protected]>
1 parent efc8f83 commit 9f86899

File tree

2 files changed

+10
-15
lines changed

2 files changed

+10
-15
lines changed

sdk/cosmos/azure-cosmos/CHANGELOG.md

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,6 @@
55
This version and all future versions will require Python 3.6+. Python 2.7 is no longer supported.
66
We will also be removing support for Python 3.6 and will only support Python 3.7+ starting December 2022.
77

8-
#### Features Added
9-
10-
#### Breaking Changes
11-
12-
#### Bugs Fixed
13-
14-
#### Other Changes
15-
168
### 4.3.0b1 (2021-12-14)
179
**New features**
1810
- Added language native async i/o client

sdk/cosmos/azure-cosmos/azure/cosmos/aio/cosmos_client.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -141,25 +141,28 @@ async def close(self):
141141
await self.__aexit__()
142142

143143
@classmethod
144-
def from_connection_string(cls, conn_str, credential=None, **kwargs):
145-
# type: (str, Optional[Any], str, Any) -> CosmosClient
144+
def from_connection_string(cls, conn_str, credential=None, consistency_level="Session", **kwargs):
145+
# type: (str, Optional[Union[str, Dict[str, str]]], str, Any) -> CosmosClient
146146
"""Create a CosmosClient instance from a connection string.
147147
148148
This can be retrieved from the Azure portal.For full list of optional
149149
keyword arguments, see the CosmosClient constructor.
150150
151-
:param str conn_str: The connection string.
151+
:param conn_str: The connection string.
152+
:type conn_str: str
152153
:param credential: Alternative credentials to use instead of the key
153154
provided in the connection string.
154-
:type credential: str or dict(str, str)
155-
:keyword str consistency_level:
156-
Consistency level to use for the session. The default value is "Session".
155+
:type credential: str or Dict[str, str]
156+
:param conn_str: The connection string.
157+
:type conn_str: str
158+
:param consistency_level: Consistency level to use for the session. The default value is "Session".
159+
:type consistency_level: str
157160
"""
158161
settings = _parse_connection_str(conn_str, credential)
159162
return cls(
160163
url=settings['AccountEndpoint'],
161164
credential=credential or settings['AccountKey'],
162-
consistency_level=kwargs.get('consistency_level', 'Session')
165+
consistency_level=consistency_level,
163166
**kwargs
164167
)
165168

0 commit comments

Comments
 (0)