# How to create a Lambda function with Python and CockroachDB Serverless

DevFeed: [How to create a Lambda function with Python and CockroachDB Serverless](<https://devfeed.tech/articles/how-to-create-a-lambda-function-with-python-and-cockroachdb-serverless-23752.md>)

Original publisher: [Read original article](<https://cockroachlabs.com/blog/aws-lambda-function-python-cockroachdb-serverless>)

Author: Charlie Custer

Published: 2022-03-08T00:00:00Z

Content type: tutorial

Language: en

Sources: [Cockroach Labs](<https://devfeed.tech/sources/cockroach-labs.md>)

Topics: [CockroachDB](<https://devfeed.tech/topics/cockroachdb.md>), [AWS Lambda](<https://devfeed.tech/topics/aws-lambda.md>), [Python](<https://devfeed.tech/topics/python.md>), [Serverless](<https://devfeed.tech/topics/serverless.md>), [Database](<https://devfeed.tech/topics/database.md>), [vendor lock-in](<https://devfeed.tech/topics/vendor-lock-in.md>)

Tags: [aws-lambda](<https://devfeed.tech/tags/aws-lambda.md>), [cockroachdb](<https://devfeed.tech/tags/cockroachdb.md>), [command-line](<https://devfeed.tech/tags/command-line.md>), [database](<https://devfeed.tech/tags/database.md>), [how-to](<https://devfeed.tech/tags/how-to.md>), [python](<https://devfeed.tech/tags/python.md>), [serverless](<https://devfeed.tech/tags/serverless.md>), [vendor-lock-in](<https://devfeed.tech/tags/vendor-lock-in.md>)

## AI overview

A tutorial showing how to create and deploy an AWS Lambda function in Python that connects to a CockroachDB Serverless database. It explains the example function, its supporting files, database connection, and generated sample account data.

## Source excerpt

Do you love thinking about servers? Most developers don't. That's why serverless platforms such as AWS Lambda, which lets you run functions in the cloud without having to think about servers, have become so popular. Running your code in the cloud doesn't truly free you from thinking about servers unless you're also using a serverless database, though. Amazon itself offers a serverless database called Amazon Aurora Serverless, but what if you prefer the advantages that CockroachDB offers, or simply want to avoid vendor lock-in with your database in case you choose to migrate to a different cloud in the future?