diff options
author | Aurélien Bompard <aurelien@bompard.org> | 2012-11-26 15:49:55 +0100 |
---|---|---|
committer | Aurélien Bompard <aurelien@bompard.org> | 2012-11-26 15:49:55 +0100 |
commit | 502795661ba7a5f356b79a42e569e118b0be0ed0 (patch) | |
tree | 4345598840fd762669fa6b06f4d1866f49576e43 | |
parent | 7d949f65c29d0d89f8e31423c00175b04a8448c2 (diff) | |
download | kittystore-502795661ba7a5f356b79a42e569e118b0be0ed0.tar.gz kittystore-502795661ba7a5f356b79a42e569e118b0be0ed0.tar.xz kittystore-502795661ba7a5f356b79a42e569e118b0be0ed0.zip |
Add a script to manually update the DB schemav0.1.2
-rw-r--r-- | kittystore/scripts.py | 49 | ||||
-rwxr-xr-x | setup.py | 1 |
2 files changed, 50 insertions, 0 deletions
diff --git a/kittystore/scripts.py b/kittystore/scripts.py new file mode 100644 index 0000000..d882d9a --- /dev/null +++ b/kittystore/scripts.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- + +# Copyright (C) 2011-2012 by the Free Software Foundation, Inc. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +# USA. + +""" +Various utility scripts. + +Author: Aurelien Bompard <abompard@fedoraproject.org> +""" + + +from optparse import OptionParser + +from kittystore import get_store + + +def updatedb(): + parser = OptionParser(usage="%prog -s store_url") + parser.add_option("-s", "--store", help="the URL to the store database") + parser.add_option("-d", "--debug", action="store_true", + help="show SQL queries") + opts, args = parser.parse_args() + if opts.store is None: + parser.error("the store URL is missing (eg: " + "sqlite:///kittystore.sqlite).") + if args: + parser.error("no arguments allowed.") + print 'Upgrading the database schema if necessary...' + store = get_store(opts.store, debug=opts.debug) + version = list(store.db.execute( + "SELECT patch.version FROM patch " + "ORDER BY version DESC LIMIT 1" + ))[0][0] + print "Done, the current schema version is %d." % version @@ -43,6 +43,7 @@ setup( entry_points={ 'console_scripts': [ 'kittystore-import = kittystore.import:main', + 'kittystore-updatedb = kittystore.scripts:updatedb', ], }, ) |