---
title: "Python Datasets"
description: "Simple database abstraction with Python dataset library. Practical notes and code examples on Python Datasets by Hemanth HM."
url: "https://h3manth.com/scribe/python-datasets/"
canonical_url: "https://h3manth.com/scribe/python-datasets/"
markdown_url: "https://h3manth.com/scribe/blog/python-datasets.md"
publishDate: "2014-09-14T00:00:00.000Z"
author: "Hemanth HM"
category: "python"
tags: ["python","db"]
word_count: 66
reading_time_minutes: 1
x_markdown_tokens: 254
content_signal: "ai-train=yes, search=yes, ai-input=yes"
---

# Python Datasets

> Simple database abstraction with Python dataset library. Practical notes and code examples on Python Datasets by Hemanth HM.

[dataset](https://dataset.readthedocs.org/en/latest/) - databases for lazy people!

## Install

pip install dataset

## Why dataset?

Normal SQLite (26 lines):
conn = sqlite3.connect(':memory:')
c = conn.cursor()
c.execute('CREATE TABLE IF NOT EXISTS sometable...')
## ... lots more code

With dataset (6 lines):python
import dataset
db = dataset.connect('sqlite:///:memory:')
table = db['sometable']
table.insert(dict(name='John Doe', age=37))
table.insert(dict(name='Jane Doe', age=34, gender='female'))
john = table.find_one(name='John Doe')
```

Sweet! 🍯

See also: [Sequel::Dataset](http://sequel.jeremyevans.net/rdoc/classes/Sequel/Dataset.html) for Ruby.
