Speed up SQLite select with Python and wx.ListCtrl -


i'm using python 2.7.5+ on kubuntu 13.10 wx 2.8.12.1.

i have not big database (about 3150 rows) have single table of employees (firstname, lastname, address, phone, email). in application store them in sqlite database , use wx.listctrl show rows user.

however, loading such database wx.listctrl takes ages (more 10 seconds think). the question is: possible improve select speed?

firstly, in python code, create table:

def createemployeestable(self):         connection = sqlite.connect(self.dbname)         try:             connection:                 cursor = connection.cursor()                 sql = '''\                     create table if not exists employees (                         id integer primary key not null,                         firstname text,                         lastname text,                         email text,                         address text,                         phone text)                 '''                 cursor.execute(sql)         finally:             connection.close() 

then, insert employees' data , select show data in pop-up window wx.listctrl on it:

def getallemployees(self):         employees = []         connection = sqlite.connect(self.dbname)         try:             connection:                 cursor = connection.cursor()                 sql = "select firstname, lastname, email, phone, address employees"                 cursor.execute(sql)                 (firstname, lastname, email, phone, address, ) in cursor:                     employees.append(employee(firstname, lastname, email, phone, address))         finally:             connection.close()         return employees 

many help.

you need use virtual version of wx.listctrl. it's mentioned in documentation follows:

a special case of report view quite different other modes of list control virtual control in items data (including text, images , attributes) managed main program , requested control when needed allows have controls millions of items without consuming memory.

there don't seem in way of examples, did find thread might put on right track:

there's complete example in wxpython demo has 1,000,000 items in it, should check out.


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

jquery - javascript onscroll fade same class but with different div -