Migrating from 0.x to 1.x

If you are currently a user of a 0.x version of the Python SDK, and intend to upgrade the SDK version to 1.x, please consider the following breaking changes. We documented all changes to promoted the SDK to GA in the ticket xataio/xata-py#24.

Status: future breaking xataio/xata-py#101

The response of an API used to of type requests.Response, this changed in favour of a custom class called ApiResponse. This class inherits the build in dict data type and hence allows to drop the previously needed .json() method to get access to data. The method .json() is still available, for a non-breaking upgrade, but pronounced deprecated and will be removed with the next major release. The properties status_code and headers are replicated. For further convenience you don't need to check the status code anymore, you can simply use the method is_success() to check if the request was successful.

In 0.x getting a record required the .json() to access the data.

post = xata.records().getRecord("Posts", "12345")
print(post.json()) # {"record": {"id": "12345", "title": "a blog post"}}

In 1.0.0 the response is implied to be a dict and ready to be used.

post = xata.records().get("Posts", "12345")
print(post) # {"record": {"id": "12345", "title": "a blog post"}}
 
# alternatively, the legacy way using .json()
post = xata.records().get("Posts", "12345")
print(post.json()) # {"record": {"id": "12345", "title": "a blog post"}}

Status: breaking xataio/xata-py#93

The API surface was clunky with duplicate names, creating long function calls and did not comply with pep-8 function names.

Listing all databases in 0.x

list = xata.databases().getDatabaseList()

changed to a more concise call in 1.x:

list = xata.databases().list()

Continously the function arguments are also converted to the pep-8 standard, lowercased and separated by an underscore, SessionId becomes session_id.

Status: breaking

In order to align with the pep-8 standard that defines the naming to exceptions, the following classes were renamed:

  • UnauthorizedException to UnauthorizedError
  • RateLimitException to RateLimitError
  • ServerErrorException to XataServerError

If a requests results in a HTTP status code not in the 2xx range, an error will be raised. The errors depend on the status code:

  • 401: UnauthorizedError
  • 429: RateLimitError
  • 500: XataServerError

Status: breaking xataio/xata-py#17

The following methods were pronounced deprecated with the 0.7.0 release of the SDK and were removed with the 1.0.0 major version:

  • client.get()
  • client.post()
  • client.put()
  • client.patch()
  • client.delete()
  • client.request()