Share your repls and programming experiences

← Back to all posts
ReplDBSQL - repl db now with sqlite3
h
MarcusWeinberger (590)

now use your repl db as a full sqlite3 database

run advanced queries, and more!

Usage

  • create a new file in your python repl (called db.py for example) and copy this code in
  • in your main.py file, add from db import ReplDBSQL
  • use it like so
db = ReplDBSQL()

con = db.connect() # returns an sqlite3 db instance
cur = con.cursor() # as normal
cur.execute('CREATE TABLE users (ID INT)')
con.close()
db.commit() # save changes

# alternatively
db.run('INSERT INTO users (ID) VALUES (1)') # does the same as above
users = db.run('SELECT * FROM users WHERE ID = ?', (1,))
Commentshotnewtop
HahaYes (1250)

SQL is a bit overkill, but its still cool