Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

simplesqlitewrap

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

simplesqlitewrap

Simple util from which I inherit my sqlite classes

  • 0.1.15
  • PyPI
  • Socket score

Maintainers
1

Simple class that wraps around the sqlite3.conn().cursor().execute() method

from simplesqlitewrap import Database

class DbWrapper(Database):
    def create_tables(self):
    	self._execute('CREATE TABLE IF NOT EXISTS Users (user_id INTEGER PRIMARY KEY, first_name NVARCHAR);')

    def insert_users(self, users, **kwargs):
    	return self._execute('INSERT OR IGNORE INTO Users (user_id, first_name) VALUES (?, ?)', users, many=True, **kwargs)

    def select_users(self, **kwargs):
    	# returns the list of all the records in 'Users'
    	return self._execute('SELECT * FROM Users', fetchall=True, **kwargs)

db = DbWrapper('database.sqlite')
print(db)

db.create_tables()

params = [(1, 'Bob'), (2, 'Charlie')]
rows_inserted = db.insert_users(params, rowcount=True)
print('Rows inserted:', rows_inserted)

users = db.select_users(as_namedtuple=True)
for user in users:
	print('ID:', user.user_id, 'first name:', user.first_name)

Installation

pip install simplesqlitewrap

Disclaimer

If you stumbled upon this package, please remember that this is just a small utility I made for myself - breaking changes may be introduced without notice. Also, my first pypi package - will probably use it for tests and sheningans.

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

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc