Skip to main content

Easy Python database interaction

Project description

easy_db

easy_db is a tool designed to quickly allow Python database interaction capabilities from a consolidated, intuitive user interface provided by the "DataBase" class.

Goals

  • Make common database tasks very easy
  • Intelligently handle different database types
  • Provide intuitive, consistent, Pythonic methods for accessing data
  • Provide good performance without requiring polished query code
  • Expose database connection and cursor to users wanting fine-grained control
  • Just get the data into Python so we can use it!

Quick Start

Let's first connect to a SQLite database.

import easy_db
db = easy_db.DataBase('test_sqlite3_db.db')

Now let's see what tables are available in this database.

tables = db.pull_all_table_names()

Table columns and types are simple to investigate.

print(db.table_columns_and_types('example_table'))

Let's pull all of the data from a table. We could start with something like "SELECT * ..." but this is way more fun:

data = db.pull_table('example_table')

Note that the table/query data is returned as a list of dictionaries with column names as dictionary keys.

  • Pro Tip: If desired, a Pandas dataframe of the same form as the database table can be easily created from this data structure using:
import pandas
df = pandas.DataFrame(data)

Now perhaps we have an Access database and would like to pull in a table from our SQLite database. easy_db makes this quick and easy and gracefully handles the nuances of dealing with the different databases.

import easy_db

db = easy_db.DataBase('test_sqlite3_db.db')
db_2 = easy_db.DataBase('test_access_db.accdb')

db_2.copy_table(db, 'example_table')

Thanks for checking out easy_db, and please take a look at the methods of the DataBase class if you'd like to see what other capabilities are currently available!

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

easy_db-0.5.11.tar.gz (8.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

easy_db-0.5.11-py3-none-any.whl (9.1 kB view details)

Uploaded Python 3

File details

Details for the file easy_db-0.5.11.tar.gz.

File metadata

  • Download URL: easy_db-0.5.11.tar.gz
  • Upload date:
  • Size: 8.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.0

File hashes

Hashes for easy_db-0.5.11.tar.gz
Algorithm Hash digest
SHA256 c881954760ff44e7cc137f81bcc6f17d8bd9f44ed8f8d1d014302499647e0611
MD5 4afa1f91c9978d1df29abd2b4ad69a83
BLAKE2b-256 efaee2c04a2830597398daa325528a6f1678da518dc200278550c4cced3900df

See more details on using hashes here.

File details

Details for the file easy_db-0.5.11-py3-none-any.whl.

File metadata

  • Download URL: easy_db-0.5.11-py3-none-any.whl
  • Upload date:
  • Size: 9.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.0

File hashes

Hashes for easy_db-0.5.11-py3-none-any.whl
Algorithm Hash digest
SHA256 369c140b4e2bd625b6505b279ff87e909d71c8ee36db7fdf78a759b13b18499d
MD5 c857aef558c04152f5a88ab9c1d72972
BLAKE2b-256 f6b11e1a6440dd4a9eb9adaa4d0199f417e583b67de8b7ddd0e5a2045fe8fccb

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page