Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

load SQLite db into memory

import sqlite3
from io import StringIO

def init_sqlite_db(app):
    # Read database to tempfile
    con = sqlite3.connect(app.config['SQLITE_DATABASE'])
    tempfile = StringIO()
    for line in con.iterdump():
        tempfile.write('%s
' % line)
    con.close()
    tempfile.seek(0)

    # Create a database in memory and import from tempfile
    app.sqlite = sqlite3.connect(":memory:")
    app.sqlite.cursor().executescript(tempfile.read())
    app.sqlite.commit()
    app.sqlite.row_factory = sqlite3.Row
Comment

PREVIOUS NEXT
Code Example
Python :: how to access specific index of matrix in python 
Python :: Permission error 
Python :: how to plot graph between f1 score and random forest parameters 
Python :: django insert data into database without form 
Python :: How to secure an endpoint for selected users with Flask-JWT-Extended 
Python :: python pyramid pattern 
Python :: Pull data from one couchdb doc via ids in another (Python) 
Python :: singke line expresions python 
Python :: typing effect in python 
Python :: python 3.9.13 release date 
Python :: linkedin bot python 
Python :: how to scrape data from github api python 
Python :: ring add new items to the list using the string index 
Python :: swagger django 
Python :: python sort dict by sub value 
Python :: get length of list python 
Python :: ret, img_frame = cap.read() 
Python :: OfficeApi 
Python :: dice throw program in python 
Python :: Find dataframe column values containing a certain string 
Python :: ticklabels are not centered heatmap 
Python :: run django using nssm 
Python :: python syntax error jedi 
Python :: keras name layers 
Python :: pyqt line edit mouse position change 
Python :: affinity propagation cosine similarity python 
Python :: how to iterate a dictionary with minimum value in python 
Python :: django file field from base64 
Python :: move to next iteration of for loop python 
Python :: Print Multiple Variables 
ADD CONTENT
Topic
Content
Source link
Name
6+8 =