1
0
mirror of https://github.com/ElvishArtisan/rivendell.git synced 2025-04-14 00:29:50 +02:00

2017-06-08 Fred Gleason <fredg@paravelsystems.com>

* Added 'scripts/engine_conv.py'.
This commit is contained in:
Fred Gleason 2017-06-08 17:50:29 -04:00
parent 5ab1be62e4
commit 1bda51a91a
3 changed files with 71 additions and 0 deletions

@ -15824,3 +15824,5 @@
argument of 'localhost' be sent to the localhost.
2017-06-05 Fred Gleason <fredg@paravelsystems.com>
* Added a 'Air Gate' ['AG'] RML.
2017-06-08 Fred Gleason <fredg@paravelsystems.com>
* Added 'scripts/engine_conv.py'.

@ -428,6 +428,7 @@ rm -rf $RPM_BUILD_ROOT
%doc docs/WINGS_FILTER.txt
%doc docs/RIVENDELL_FILTER.txt
%doc docs/NEXGEN_FILTER.txt
%doc scripts/engine_conv.py
%files devel

68
scripts/engine_conv.py Executable file

@ -0,0 +1,68 @@
#!/usr/bin/python
# engine_conv.py
#
# Convert a Rivendell database to use a different MySQL table engine
#
# (C) Copyright 2017 Fred Gleason <fredg@paravelsystems.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.
#
# 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., 675 Mass Ave, Cambridge, MA 02139, USA.
#
# Usage: engine_conv.py <engine>
from __future__ import print_function
import ConfigParser
import mysql.connector
import sys
def eprint(*args,**kwargs):
print(*args,file=sys.stderr,**kwargs)
def GetDbCredentials():
config=ConfigParser.ConfigParser()
config.readfp(open('/etc/rd.conf'))
return (config.get('mySQL','Loginname'),config.get('mySQL','Password'),
config.get('mySQL','Hostname'),config.get('mySQL','Database'))
def OpenDb():
creds=GetDbCredentials()
return mysql.connector.connect(user=creds[0],password=creds[1],
host=creds[2],database=creds[3],buffered=True)
if(len(sys.argv)<2):
eprint("engine_conv.py: missing <engine> argument")
exit(256)
engine=sys.argv[1]
db=OpenDb()
creds=GetDbCredentials()
sql='select TABLE_NAME,ENGINE from information_schema.TABLES where TABLE_SCHEMA="'+creds[3]+'" && ENGINE!="'+engine+'"'
q=db.cursor()
q.execute(sql)
for row in q.fetchall():
print('Converting table "'+row[0]+'" to '+engine)
sql='alter table `'+row[0]+'` engine='+engine
q1=db.cursor()
q1.execute(sql)
db.commit()
q1.close()
q.close()
db.close()