Socket
Socket
Sign inDemoInstall

mysqldbhelper

Package Overview
Dependencies
0
Maintainers
1
Alerts
File Explorer

Install Socket

Detect and block malicious and high-risk dependencies

Install

    mysqldbhelper

A simple wrapper over mysqldb


Maintainers
1

Readme

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

FAQs


Did you know?

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc