Re: creating tables needed for a query on-demand
Ed Pasma <[email protected]>
| Newsgroups | gmane.comp.python.db.pysqlite.user |
|---|---|
| Message-ID | <[email protected]> |
Hello Ryan, using the authorizer seems not to "hacky", at least you rely on SQLite's own parser. As yiu found, the authorizer is only invoked if there are no errors, so the tables must at least exist. But another restriction to be aware of is that it only applies to statement preparation. So, whith the PySQLite statement cache, it will not work the second time a statement is executed, if that may happen. By the way, it is hard to understand why you need this. And I see now that SQLite lets you define triggers on select statements (but likely these do not allow data manipulation). Regards, Edzard Pasma Op 2-feb-2007, om 19:52 heeft Ryan Blazecka het volgende geschreven: > > Andy Chambers wrote: >> How about putting the query inside a try .. except block? >> >> > the problem is that since the query is coming from the user, I have no > idea which table is causing the statement to fail. in addition, the > table may exist, but I need to update it's contents before running the > query. in this case, I wouldn't even get an error, it would just be > operating on out-of-date data. > > I haven't tried it yet, but I'm hoping I can use the authorizer to > catch > this "out-of-date" case. if so, I could solve the other case by > pre-creating all of the tables, but only populating them when the user > actually queries against them. > > this still seems a little hacky though - I really don't think it's > what > an authorizer is intended to be used for. ;) > > thanx, > ryan > _______________________________________________ > pysqlite mailing list > pysqlite-IAPFreCvJWPBWskQ1e/[email protected] > http://lists.initd.org/mailman/listinfo/pysqlite >