Skip to main content

Simplify DB API usage

Project description

Patabase

Database API as it described in PEP 249 is a comprehensive API. It's amazing and we can implement any advanced scenario with it. But for a simple task we don't need an advanced or comprehensive tool. We just need a simple tool to do the job for us. After all we all agree that "Simple is better than complex."

Installation

We'd like to support all the databases, but we don't like to install all the drivers of all the databases. So first of all install and config your database driver then install corresponding python package:

pip install -U psycopg2  # for Postgres

pip install -U pyodbc  # for Microsoft SQL Server 

now you can install it from PyPi by following command:

pip install -U patabase

or if you prefer the latest development version, you can install it from the source:

git clone https://github.com/xurvan/patabase.git
cd patabase
python setup.py install

Quickstart

SQL commands are usually categorized into DDL, DQL, DML, DCL and TCL but we are going to categorized them into different categories:

  • Select: a command with output that is not going to change anything
  • Perform: a command without output that is going to change something
  • Function: a stored procedure with output
  • Procedure: a stored procedure without output

so let us see some code:

from patabase import Postgres

db = Postgres(host='localhost', user='USERNAME', password='PASSWORD', database='DATABASE_NAME')

db.perform('''
create table users
(
    id          serial primary key not null,
    name        varchar            not null,
    username    varchar unique     not null
)
''')

rows = db.select('select * from users')

for row in rows:
    print(row)

TODO

  • <input type="checkbox" checked="" disabled="" /> Support PostgreSQL
  • <input type="checkbox" checked="" disabled="" /> Support Microsoft SQL Server
  • <input type="checkbox" disabled="" /> Support SQLite
  • <input type="checkbox" disabled="" /> Support MySQL
  • <input type="checkbox" disabled="" /> Support Oracle Database

Project details


Download files

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

Files for patabase, version 0.2.2
Filename, size File type Python version Upload date Hashes
Filename, size patabase-0.2.2-py3-none-any.whl (8.4 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size patabase-0.2.2.tar.gz (3.8 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page