Thread: [SQLObject] is there a way to (re)set generator?
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: Petr J. <pet...@tp...> - 2010-04-19 04:34:45
|
Hi, because of the security issues, I am deleting rows in some tables (* destroySelf *method) and I do not want anybody to find, how many rows were inserted in the past in to the table.* *I just wonder if there is a way to (re)set generators to the initial value (1). Best Regards Petr Jakes * * |
From: Oleg B. <ph...@ph...> - 2010-04-19 09:50:23
|
On Mon, Apr 19, 2010 at 06:34:37AM +0200, Petr Jake?? wrote: > I do not want anybody to find, how many rows were > inserted in the past in to the table.* At what level do you want to forbid to run SELECT COUNT(*)? if a user can connect to the DB and run queries on the table [s]he can run the query directly, right? > *I just wonder if there is a way to (re)set generators to the initial value > (1). In general, there is no way. The only way to reset a generator is to create a new generator. Oleg. -- Oleg Broytman http://phd.pp.ru/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |
From: Petr J. <pet...@tp...> - 2010-04-19 11:27:34
|
> At what level do you want to forbid to run SELECT COUNT(*)? if a user > can connect to the DB and run queries on the table [s]he can run the query > directly, right? > If records are deleted say daily (or on some regular basis), then SELECT COUNT(*) is nearly useless. Of course the secured backup (csv) before processing row.destroySelf is necessary. Try to imagine government is offending you for example... :( > > > *I just wonder if there is a way to (re)set generators to the initial > value > > (1). > > In general, there is no way. The only way to reset a generator is to > create a new generator. > > As I am on the Firebird, I can see only dropTable, createTable methods in the: http://www.sqlobject.org/sqlobject/firebird/firebirdconnection.py.html There is not particular method to create new generator. Regards Petr |
From: Oleg B. <ph...@ph...> - 2010-04-19 11:38:05
|
On Mon, Apr 19, 2010 at 01:27:25PM +0200, Petr Jake?? wrote: > As I am on the Firebird, I can see only dropTable, createTable methods in > the: > > http://www.sqlobject.org/sqlobject/firebird/firebirdconnection.py.html > > There is not particular method to create new generator. OMG, you did mean FB generator, not Python! You need to be more specific. (-: You need to run your own SQL queries. Something like this: self.query("DROP GENERATOR GEN_%s" % soClass.sqlmeta.table) self.query("CREATE GENERATOR GEN_%s" % soClass.sqlmeta.table) And there is perhaps SQL commands to reset the generator. I know nothing about FB so I cannot help. Look it up in the FB docs. Oleg. -- Oleg Broytman http://phd.pp.ru/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |
From: Petr J. <pet...@tp...> - 2010-04-19 11:52:33
|
> OMG, you did mean FB generator, not Python! You need to be more specific. > (-: > > Sorry about that, my feeling was all SQL engines are using ID generators to store in it. > You need to run your own SQL queries. Something like this: > > self.query("DROP GENERATOR GEN_%s" % soClass.sqlmeta.table) > self.query("CREATE GENERATOR GEN_%s" % soClass.sqlmeta.table) > > And there is perhaps SQL commands to reset the generator. I know nothing > about FB so I cannot help. Look it up in the FB docs. > This is not a problem, I was just wondering if I am not overlooking something more Pythonic. Thanks for your comments anyway. Regards Petr Jakes |
From: Oleg B. <ph...@ph...> - 2010-04-19 12:57:55
|
On Mon, Apr 19, 2010 at 01:52:31PM +0200, Petr Jake?? wrote: > > OMG, you did mean FB generator, not Python! You need to be more specific. > > (-: > > Sorry about that, my feeling was all SQL engines are using ID generators to > store in it. They use, but some of them are internal and don't have any SQL-based access. For example, SQLite internally use MAX(id); this means if you delete some rows, id could be reused. MySQL has an internal monotonous generator that can only be queried with SELECT LAST_INSERT_ID(). Postgres has generators (called "sequences") with full SQL-based access; one can query and set them at will. Oleg. -- Oleg Broytman http://phd.pp.ru/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |