npm-packages/docs/docs/quickstart/python.mdx
import sampleData from "!!raw-loader!@site/../demos/python-quickstart/sampleData.jsonl"; import tasks from "!!raw-loader!@site/../demos/python-quickstart/convex/tasks.js"; import main from "!!raw-loader!@site/../demos/python-quickstart/main.py";
Learn how to query data from Convex in a Python app.
<StepByStep> <Step title="Create a Python script folder"> Create a folder for your Python script with a virtual environment.```sh
python3 -m venv my-app/venv
```
And also install the `convex` Python client
library and `python-dotenv` for working with `.env` files.
```sh
cd my-app && npm init -y && npm install convex && venv/bin/pip install convex python-dotenv
```
It will also create a `convex/` folder for you
to write your backend API functions in. The `dev` command
will then continue running to sync your functions
with your dev deployment in the cloud.
```sh
npx convex dev
```
<Snippet
source={sampleData}
title="sampleData.jsonl"
/>
```
npx convex import --table tasks sampleData.jsonl
```
Exporting a query function from this file
declares an API function named after the file
and the export name, `"tasks:get"`.
<Snippet
source={tasks}
title="convex/tasks.js"
/>
<Snippet
source={main}
title="main.py"
/>
```sh
venv/bin/python -m main
```
See the docs on PyPI for more details.