Skip to main content
Join the official 2019 Python Developers SurveyStart the survey!

A simple database helper.

Project description

slimdbhelper: A simple database helper.

usage:

from slimdbhelper import PostgreSqlHelper,SQliteHelper


# PostgreSqlHelper example
with PostgreSqlHelper(host, port, database, user, password) as db:
    db.execute('''
    CREATE TABLE foo
    (
    id integer PRIMARY key,
    txt text
    )
    ''')
    db.execute("insert into foo values(%s,%s)",(1,'a'))
    db.execute("insert into foo values(%s,%s)",(2,'b'))
    db.execute("insert into foo values(%s,%s)",(3,'c'))
    db.commit()
    result = db.query("select * from foo where id=%s and txt=%s", (2, 'a'))
    print(result)
# or
db = PostgreSqlHelper(host, port, database, user, password)
db.open()
# ...
db.close()


# SQlite example
with SQliteHelper() as db:
    db.execute('''
    CREATE TABLE foo (
    id INTEGER PRIMARY KEY ,
    txt TEXT NULL
    )
    ''')
    db.execute("insert into foo values(?,?)",(1,'a'))
    db.execute("insert into foo values(?,?)",(2,'b'))
    db.execute("insert into foo values(?,?)",(3,'c'))
    db.commit()
    result = db.query("select * from foo where id=? and txt=?", (2, 'b'))
    print(result)
# or
db=SQliteHelper()
db.open()
# ...
db.close()

Project details


Release history Release notifications

Download files

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

Files for slimdbhelper, version 1.0.5
Filename, size File type Python version Upload date Hashes
Filename, size slimdbhelper-1.0.5-py3-none-any.whl (7.3 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size slimdbhelper-1.0.5.tar.gz (2.5 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page