与carto帐户交互的命令行应用程序
carto-cli的Python项目详细描述
$ carto-cli
待办事项
- 完成可视化和命名地图交互
- 为格式和默认帐户设置默认系统
- 向
carto_env
添加子命令以添加、更新和删除条目 - 支持新的
COPY
方法 - 支持auth api 3
tl;dr
一组简单的命令行应用程序,用于与您自己的carto帐户交互。
如何
如何安装
软件包位于pypi处,您只需运行即可:
$ pip install carto-cli
如何贡献
您可以派生repo并为运行pip install --editable .
从那里你可以提出任何修复或改进拉请求。当这更成熟时,我将记录如何贡献一个新的子命令,但您实际上可以查看setup.py
文件,然后查看不同文件夹的任何脚本。
关于环境变量
这里的所有工具默认使用一些环境变量。如果您只管理一个carto帐户,那么您可以在您的环境使用的任何初始化脚本中设置它们,例如使用这些变量的~/.bashrc
或/etc/environment
:
CARTO_USER
:您的用户名CARTO_ORG
:如果使用开源或企业帐户,则为carto组织的名称CARTO_API_KEY
:与carto引擎交互的api键CARTO_API_URL
:如果不使用carto.com
帐户,则需要在此处放置相当于api端点的值。对于carto.com
帐户,应该是http://user.carto.com/
CARTO_CHECK_SSL
:如果您正在使用自己的服务器,并且没有安装正确的证书,请将此变量设置为false
设置这些变量将节省对命令行应用程序的任何调用,从而节省大量复制粘贴工作。
carto_env
如果你碰巧使用一套不同的卡托帐户,这个工具是为你。这依赖于一个结构非常简单的yaml文件。此命令会将信息加载到终端中,以便您可以复制粘贴一次并导出会话的环境变量,或者如果您具有$CARTO_ENV
环境或使用-o
参数,它会将其保存在文件中,以便您可以对其进行源代码管理。
$ carto_env -h
Usage: carto_env [OPTIONS] COMMAND [ARGS]...
Allows you to get the account details
Options:
-c, --config-file FILENAME Configuration file to read, defaults to
~/.cartorc.yaml or the environment variable
$CARTO_DB
-h, --help Show this message and exit.
Commands:
list List your stored users
load The user wou want to retrieve
search Returns the user names that match the given...
version Prints the version of this application
因此,如果您的$CARTO_ENV
环境指向例如/tmp/cartoenv
,那么您可以使用以下命令加载数据库的任何用户:
$ carto_env load jsanz $ source /tmp/cartoenv;echo$CARTO_API_URL
配置文件
使用此结构存储名为(默认情况下)的yaml
文件~/.cartorc.yaml
---jsanz:api_key:your_api_keyorganization:teamrandom_key:user:your_userapi_key:another_api_keyorganization:teamonprem_user:api_key:your_api_keyorganization:myorgurl:http://myserver.mydomain.com/user/username
默认情况下,密钥将是您的帐户名,但您可以指定一个user
密钥,以便为您的配置项使用不同的名称。
note:还要记住,carto内部部署实例通常配置为无域设置,因此用户名必须在url中指定,如上面的最后一个示例所示,其中url
设置为https://onprem-host/user/username
。
carto_sql
$ carto_sql -h
Usage: carto_sql [OPTIONS] COMMAND [ARGS]...
Performs different actions against the SQL API
Options:
-u, --user-name TEXT Your CARTO.com user. It can be omitted if
$CARTO_USER is available
-o, --org-name TEXT Your organization name. It can be ommitted if
$CARTO_ORG is available
-a, --api-url TEXT If you are not using carto.com you need to specify
your API endpoint. It can be omitted if
$CARTO_API_URL is available
-k, --api-key TEXT It can be omitted if $CARTO_API_KEY is available
-c, --check-ssl BOOLEAN Check server SSL Certificate (default = True or
CARTO_CHECK_SSL envvar)
-h, --help Show this message and exit.
Commands:
functions Functions on your account
kill Kills a query based on its pid
queries Shows the current running queries
run Execute a SQL passed as a string
schemas List your organization schemas
version Prints the version of this application
检查每个命令的详细信息,因为它们有特殊的选项。
carto_batch
$ carto_batch -h
Usage: carto_batch [OPTIONS] COMMAND [ARGS]...
Performs different actions against the Batch SQL API
Options:
-u, --user-name TEXT Your CARTO.com user. It can be omitted if
$CARTO_USER is available
-o, --org-name TEXT Your organization name. It can be ommitted if
$CARTO_ORG is available
-a, --api-url TEXT If you are not using carto.com you need to specify
your API endpoint. It can be omitted if
$CARTO_API_URL is available
-k, --api-key TEXT It can be omitted if $CARTO_API_KEY is available
-c, --check-ssl BOOLEAN Check server SSL Certificate (default = True or
CARTO_CHECK_SSL envvar)
-h, --help Show this message and exit.
Commands:
cancel Cancels a job
create Creates a new job and returns its ID
list Display the ids of all your running jobs
read Returns details about a job id (JSON)
version Prints the version of this application
carto_dataset
命令使用帐户数据集,从中获取信息,上载和 下载数据等。
$ carto_dataset -h
Usage: carto_dataset [OPTIONS] COMMAND [ARGS]...
Performs different actions against the SQL API
Options:
-u, --user-name TEXT Your CARTO.com user. It can be omitted if
$CARTO_USER is available
-o, --org-name TEXT Your organization name. It can be ommitted if
$CARTO_ORG is available
-a, --api-url TEXT If you are not using carto.com you need to specify
your API endpoint. It can be omitted if
$CARTO_API_URL is available
-k, --api-key TEXT It can be omitted if $CARTO_API_KEY is available
-c, --check-ssl BOOLEAN Check server SSL Certificate (default = True or
CARTO_CHECK_SSL envvar)
-h, --help Show this message and exit.
Commands:
cartodbfy Runs the cartodbfication of a table to...
delete Deletes a dataset from your account
describe Report of all your table details
download Download a dataset
edit Edit dataset properties
indexes List your table associated indexes
list Display all your CARTO datasets
list_tables List tables and their main Postgres...
merge Merges a number of datasets
rename Renames a dataset from your account
schema Shows your dataset attributes and types
triggers List your table associated triggers
upload Upload a new dataset from a file on your...
version Prints the version of this application
carto_map
管理地图