Skip to main content

Makes working with existing sql databases super easy

Project description

HPDB

Current version: 4.0.7

dbClass

installation

python -m pip install hpdb

usage

settings.ini

[database]
dbhost = myhost.mydomain.com
dbname = database_name
dbuser = database_user
dbpass = secret123

Initializing from ini file

from hpdb import dbClass
db = dbClass.from_inifile('settings.ini')

Initializing directly

db = dbClass(  host, dbname, user, passwd )

SELECT

db.select('users',{'isactive':1} )

LOOKUP SPECIFIC VALUES

db.lookup('users',{'id':15}, ['name', 'active] )

INSERT

db.insert('users', {'name':'john', 'isactive':1})
id = db.last_insert_id()

UPDATE

db.update( 'users', {'name':'john'}, {'active':0})

DELETE

db.delete( 'users', {'name':'john'})

QUERY

db.execute( 'SELECT * FROM users' )

Don't forget to commit when you have an innodb table

db.commit()

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

hpdb-4.0.7.tar.gz (5.0 kB view hashes)

Uploaded Source

Built Distribution

hpdb-4.0.7-py3-none-any.whl (5.7 kB view hashes)

Uploaded Python 3

Supported by

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