🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

mysqldbhelper

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mysqldbhelper

A simple wrapper over mysqldb

1.0.2
PyPI
Maintainers
1

MySqlDbHelper

For use with the mysqldb module for python

Usage

::

import mysqldbhelper
db = mysqldbhelper.DatabaseConnection('hostname',
                    user='username',
                    passwd='password',
                    db='databasename')

For single transactions

::

db.get_one('select book_name from book where isbn = %s', ('SOMEISBN',))

‘limit 1’ is automatically added

::

db.get_all('select book_name from book where author = %s', ('Richard Dawkins',))

::

db.put('''
insert into book
(book_name, book_author)
values
(%s, %s)''', ('Phantoms in the brain', 'V.S. Ramachandran')

put can be used for insert, update and delete queries

::

db.put('''delete from book
where
book_author = %s''' ('Deepak Chopra',))

For multiple transcations that need to be run atomically

::

try:
    db.start()
    db.get(...)
    db.put(...)
    ...
    db.save()
except Exception, e:
    db.rollback()
    raise

Used at Comparnion.com_

.. _Comparnion.com: https://comparnion.com

Keywords

mysql

FAQs

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts