Skip to content

Instantly share code, notes, and snippets.

@4OH4
Last active November 15, 2019 22:13
Show Gist options
  • Save 4OH4/192ea072cbb5f0899e628204b5aa1fdf to your computer and use it in GitHub Desktop.
Save 4OH4/192ea072cbb5f0899e628204b5aa1fdf to your computer and use it in GitHub Desktop.
Doctest case embedded in the class documentation for a DAO
import os
import sqlite3
class DAO(object):
"""
SQLite3 Data Access Object
Usage:
>>> dao = DAO('example.db')
Database connection initialised
"""
def __init__(self, db_filepath='example.db'):
"""Initialize DB class variables"""
self.connection = sqlite3.connect(db_filepath)
print('Database connection initialised')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment