Giter VIP home page Giter VIP logo

python-universal-db-client's Introduction

Universal Database Client

SUMMARY:
VERSION:
0.2.3
AUTHOR:
David J. Lambert
DATE:
May 31, 2019
PURPOSE:
A sample of my Python coding, to demonstrate that I can write decent Python, test it, and document it. I also demonstrate that I know relational databases and Linux.
DESCRIPTION:

This is a command-line program that asks an end-user for SQL to execute on 1 of 7 different relational databases, ordered by popularity as ranked in https://pypl.github.io/DB.html in Oct 2018:

  • Oracle
  • MySQL
  • Microsoft SQL Server
  • PostgreSQL
  • SQLite
  • IBM DB2 (untested)
  • Microsoft Access 2016

I also provide sample databases to run this program against (see below). The code for DB2 is untested.

The code for the 6 tested database types has been tested with CRUD statements (Create, Read, Update, Delete). There is nothing to prevent the end-user from entering other SQL, such as ALTER DATABASE, CREATE VIEW, and BEGIN TRANSACTION, but none have been tested.

A future version might include the ability to list databases, tables, views, indexes, and their fields without having to know the structure of any data dictionaries. This is the easiest addition to make, so it is the most probable addition to this package.

PROGRAM REQUIREMENTS:

  • For connecting to Oracle, my code uses the cx_Oracle library, which is available on PyPI. The cx_Oracle library requires the Oracle client libraries. Several ways to obtain the Oracle client libraries are documented on https://cx-oracle.readthedocs.io/en/latest/installation.html.

    Cx_Oracle v7.0.0 supports Python versions 2.7 and 3.5-3.7, and Oracle versions 11.2-18.3.

  • For connecting to MySQL, my code uses the pymysql library, which is available on PyPI.

    Pymysql v0.9.2 supports Python versions 2.7 and 3.4-3.7, plus MySQL and MariaDB versions 5.5 and newer.

  • For connecting to Microsoft SQL Server, my code uses the pymssql library, which is available on PyPI. The pymssql library requires Microsoft Visual C++ 14, which is available as "Microsoft Visual C++ Build Tools" on http://landinghub.visualstudio.com/visual-cpp-build-tools.

    Pymssql v2.1.4 supports Python versions 2.7 and 3.4-3.7, and Microsoft SQL Server versions 2005 and newer.

  • For connecting to PostgreSQL, my code uses the psycopg2 library, which is available on PyPI.

    Psycopg2 v2.7.5 supports Python versions 2.6-2.7 and 3.2-3.6, and PostgreSQL server versions 7.4-10. Python 3.7 is unsupported, but I had no problems using it.

  • For connecting to IBM DB2, my code uses the ibm_db library, which is available on PyPI. The ibm_db library library requires Microsoft Visual C++ 14, which is available as "Microsoft Visual C++ Build Tools" on http://landinghub.visualstudio.com/visual-cpp-build-tools.

    I can not find which Python versions are supported by ibm_db v2.0.9. I had no problems installing it in Python versions 2.7 and 3.3-3.7.

  • For connecting to Microsoft Access 2016, my code uses the pyodbc library, which is available on PyPI. The pyodbc library requires the "Microsoft Access Database Engine 2016 Redistributable", which is available from https://www.microsoft.com/en-us/download/details.aspx?id=54920.

    Pyodbc v4.0.24 supports Python versions 2.7 and 3.4-3.6.

  • For connecting to SQLite, my code uses the sqlite3 library, part of the Python Standard Library.

    The sqlite3 library has been in the Standard Library since Python 2.5.

SAMPLE DATABASES TO TEST THIS PROGRAM ON:

I provide 5 sample databases to run this program against, one for each of the 5 types of tested database types listed in the previous section. I have ambitions of creating sample Oracle and DB2 databases.

Sample SQLite and Microsoft Access databases are included in this package in these locations:

  • databases/ds2.sqlite3
  • databases/ds2.accdb

There are 3 VirtualBox Linux guests containing sample databases, one each for Microsoft SQL Server on Ubuntu (officially supported!), MySQL on Debian, and PostgreSQL on Debian.

The sample databases all have the same data: the small version of the Dell DVD Store database, version 2.1, available at http://linux.dell.com/dvdstore. The data is in these tables:

  • CATEGORIES -- 16 records
  • CUSTOMERS -- 20,000 records
  • CUST_HIST -- 60,350 records
  • INVENTORY -- 10,000 records
  • ORDERLINES -- 60,350 records
  • ORDERS -- 12,000 records
  • PRODUCTS -- 10,000 records
  • REORDER -- 0 records
  • I've added table db_description, containing 1 record with my name and contact information.
The MySQL sample database:
The Microsoft SQL Server sample database:
The PostgreSQL sample database:
The Microsoft Access 2016 sample database:
  • Included in this package as databases/ds2.accdb.
The SQLite sample database:
  • Included in this package as databases/ds2.sqlite3.

python-universal-db-client's People

Contributors

davidjlambert avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.