Deleting references
From Bibus
Contents |
Introduction
It is not possible to delete references in Bibus. However, because the bibus database is a SQL database, one can access the database directly with one of the command line or GUI tool available:
command line tools
GUI tool, e.g.,
- MySQL Query browser for MySQL
- SQLite Database Browser for SQLite
- See the websites for SQLite and MySQL or related websites for more products
With command line tool
When you are familiar with using SQL directly or you don't have a GUI tool, you can use one of the queries below in the command line tool. Imporant: to be on the safe side, make a backup of your database before you do it! BTW: For more general tips on the use of SQL, see: Direct access to the Bibus database
First steps in bibus
1) First make a new key named 'to_be_deleted' (you can choose any other name if you want).
2) Add all the refs you want to delete to this key.
3) One can use the following scripts for MySQL (2 queries) or SQLite (4 queries)to delete all refs that are in the 'to_be_deleted' key. They will also clean the bibreflink table that contains the links between the keys and the refs. You can save the code below in a text file and execute it in one of the above mentioned command line tools (and also using the script or query window in many GUI tools).
Queries for SQLite database
- First make a new key named 'to_be_deleted' (you can choose any other name if you want).
- Add all the refs you want to delete to this key.
- One can use the following scripts for SQLite
DELETE from bibref where id in (Select ref_id from bibreflink where key_id in (Select key_id from bibrefkey where key_name="to_be_deleted")); #if using bibus 1.4 DELETE from table_modif where ref_id in (Select ref_id from bibreflink where key_id in (Select key_id from bibrefKey where key_name='to_be_deleted')) DELETE from bibreflink where key_id in (Select key_id from bibrefkey where key_name="to_be_deleted"); DELETE from bibrefkey where key_name="to_be_deleted"; DELETE from bibreflink where ref_id not in (select id from bibref);
A simple solution is to include the scripts directly in the __getAllRef function in dbBibBase.py as follows
def __getAllRef(self,table,collist,order,how=BIB.LIST_HOW):
tmpstr="""DELETE from bibref where id in (Select ref_id from bibreflink where key_id in (Select key_id from bibrefkey where key_name='to_be_deleted'))"""
self.dbCursor.execute(tmpstr)
self.dbConnection.commit()
#uncomment the 3 following lines for bibus 1.4
tmpstr="""DELETE from table_modif where ref_id in (Select ref_id from bibreflink where key_id in (Select key_id from bibrefKey where key_name='to_be_deleted'))"""
self.dbCursor.execute(tmpstr)
self.dbConnection.commit()
tmpstr="""DELETE from bibreflink where key_id in (Select key_id from bibrefkey where key_name='to_be_deleted')"""
self.dbCursor.execute( tmpstr)
self.dbConnection.commit()
tmpstr="""DELETE from bibreflink where ref_id not in (select id from bibref)"""
self.dbCursor.execute(tmpstr)
self.dbConnection.commit()
try:
self.dbCursor.execute("""SELECT %s FROM %s ORDER BY %s +0 %s"""% (','.join(('Id',)+collist),table,order,how)) # column Id added for SetData of refList
return self.dbCursor.fetchall()
except Error,errorType:
self.showError("dbBibBase.__getAllRef " + `errorType.args`)
return None
With this function, the content of the "to_be_deleted" category is deleted each time you click on the "All" category or you launch.


