Asynchronous Python client for CARTO.
- SQL API
- Batch API
- COPY queries
- Import API
- Read and write Panda's DataFrames
- Maps API?
- Tests
pip install geolibs-cartoasync
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
>>> }
auth = Auth(username='username', api_key='api_key')
auth = Auth(base_url='https://myapp.com/user/username/', api_key='api_key')
auth = Auth(base_url='https://myapp.com/', username='username', api_key='api_key')
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.
sql_client = SQLClient(auth)
result = await sql_client.send('SELECT 1 AS one;')
import aiohttp
sql_client = SQLClient(auth)
result = await sql_client.send('SELECT 1 AS one;', aiohttp.ClientSession())