Re: [dabo-users] Grid from SQLite Views

Author: John Fabiani

Posted: 2012-03-02 at 09:31:25

On Friday, March 02, 2012 07:27:41 AM John Fabiani wrote:

> On Friday, March 02, 2012 01:56:16 PM Dewald Jacobs wrote:

> > Hi,

> >

> > I have a SQLite database with a View (created with the command CREATE

> > VIEW, just to be clear) that was created by combining 2 tables plus and

> > an added column to compute JULIANDAY. How would I go about adding this

> > View in a grid in Class Designer? I want to treat this view exactly the

> > same as a normal table and have tried to implement it as such, but have

> > failed to do so.

> >

> > Any tips or advice would be much appreciated.

> >

> > Thanks

> > Dewald

>

> I don't use SQLite.

> But, looking at the code - dbSQLite.py - the views are not retrieved.

> Something like

> select name from sqlite_master where type = 'view'

> is needed.

>

> Question is how best to add in the views and will anything need changing to

> support ClassDesigner.

>

> Johnf

Opps - sent to fast!

Try this and see if it works.

In dbSQLite.py

def getTables(self, cursor, includeSystemTables=False):

cursor.execute("select * from sqlite_master")

rs = cursor.getDataSet()

if includeSystemTables:

tables = [rec["name"] for rec in rs

if rec["type"] == "table"]

else:

tables = [rec["name"] for rec in rs

if rec["type"] == "table" or rec['type'] == 'view'

and not rec["name"].startswith("sqlite_")]

return tuple(tables)

_______________________________________________

Post Messages to: Dabo-users@leafe.com

Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users

Searchable Archives: http://leafe.com/archives/search/dabo-users

This message: http://leafe.com/archives/byMID/1397013.NQbhjzTa81@linux-12

©2012 John Fabiani