Skip to main content

GeoLibs CARTOasync

Project description

GeoLibs-CARTOasync

Asynchronous Python client for CARTO.

Features

  • SQL API
  • Batch API
  • COPY queries
  • Import API
  • Read and write Panda's DataFrames
  • Maps API?
  • Tests

Installation

pip install cartoasync

Usage

SQL API example

from cartoasync import Auth, SQLClient

auth = Auth(username='username', api_key='api_key')
sql_client = SQLClient(auth)
result = await sql_client.send('SELECT 1 AS one;')

print(result)
>>> {
>>>   "rows": [
>>>     {
>>>       "one": 1
>>>     }
>>>   ],
>>>   "time": 0.002,
>>>   "fields": {
>>>     "one": {
>>>       "type": "number"
>>>     }
>>>   },
>>>   "total_rows": 1
>>> }

SQL API example, step by step

1. Instantiate an Auth object:
1.1. CARTO cloud:
auth = Auth(username='username', api_key='api_key')
1.2. CARTO OnPremises or cloud organization with an implict user:
auth = Auth(base_url='https://myapp.com/user/username/', api_key='api_key')
1.3. CARTO OnPremises or cloud organization without an implicit user:
auth = Auth(base_url='https://myapp.com/', username='username', api_key='api_key')
1.4. SSL:

The Auth constructor has and ssl attribute. You can use it for handle to the library a Python's SSL context, or set it to False for relaxing certification checks. More info on AIOHTTP doc.

2. Instantiate the SQLClient and send queries:
2.1. SQLClient's own AIOHTTP session:
sql_client = SQLClient(auth)
result = await sql_client.send('SELECT 1 AS one;')
2.2. External AIOHTTP session you need to care until the end of its days:
import aiohttp

sql_client = SQLClient(auth)
result = await sql_client.send('SELECT 1 AS one;', aiohttp.ClientSession())

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

geolibs-cartoasync-0.0.4.tar.gz (4.0 kB view details)

Uploaded Source

Built Distribution

geolibs_cartoasync-0.0.4-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

Details for the file geolibs-cartoasync-0.0.4.tar.gz.

File metadata

  • Download URL: geolibs-cartoasync-0.0.4.tar.gz
  • Upload date:
  • Size: 4.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/0.12.12 CPython/3.7.3 Linux/4.14.91+

File hashes

Hashes for geolibs-cartoasync-0.0.4.tar.gz
Algorithm Hash digest
SHA256 1637b056582c135468551ca674ab67154664d87af98808e338c91df127db5145
MD5 655bec649b54226f39f81b8969abdcc7
BLAKE2b-256 a6dd0ca70a7127c5ed627e8c9ceb09af1fa0a0853d459636428c2c72d6fa0485

See more details on using hashes here.

File details

Details for the file geolibs_cartoasync-0.0.4-py3-none-any.whl.

File metadata

File hashes

Hashes for geolibs_cartoasync-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 cc6d09f21a9d104ca3cf51e5e77839a31f414f16999566c951fbaa816960933e
MD5 ac30cfffb40460af0af45564b5684a90
BLAKE2b-256 fa11b9f14625e1b825c8c2b32465b90ba7fc2270e8b898e5f855815eb61df624

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page