Skip to content

ReneNyffenegger/py-RenesSQLiteHelper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RenesSQLiteHelper

René's minimal wrapper around Python's built-in sqlite3 module.

Installation

pip install RenesSQLiteHelper

Usage

Create a database

The database file (Here: some-data) is stored by default under ~/.local/share/sqlite-dbs.

from RenesSQLiteHelper import open_db, bulk_load
con = open_db('some-data', deleteIfExists = True)

con.execute('''
create table tab (
   id  integer primary key,
   val text
)
''')

Use the database

Bulk load

con = open_db('some-data')

with bulk_load(con) as cur:
    cur.execute('insert into tab values (?, ?)', (42, 'hello world'))

Selecting etc

for rec in con.execute('select * from tab'):
    print(f'{rec['id']}: {rec['val']}')

Releases

No releases published

Packages

 
 
 

Contributors

Languages