forked from openlp/openlp
Changed script to be os independent and pure python sqlite calls
bzr-revno: 276
This commit is contained in:
parent
9887764d51
commit
7d76349d3d
@ -39,45 +39,35 @@ class MigrateSongs():
|
|||||||
self._v1_9_0_topics(database)
|
self._v1_9_0_topics(database)
|
||||||
self._v1_9_0_songbook(database)
|
self._v1_9_0_songbook(database)
|
||||||
|
|
||||||
conn = sqlite3.connect(self.data_path+"/"+database)
|
conn = sqlite3.connect(self.data_path+os.sep+database)
|
||||||
conn.text_factory = str
|
conn.text_factory = str
|
||||||
c = conn.cursor()
|
c = conn.cursor()
|
||||||
#cmd = "sqlite3 -echo "+ self.data_path+"/"+database + ' "create index if not exists sa1121 on songauthors (authorid ASC,songid ASC) ;"'
|
|
||||||
#print cmd
|
|
||||||
#f_i, f_o = os.popen4(cmd)
|
|
||||||
#out = f_o.readlines()
|
|
||||||
#print out
|
|
||||||
#self.display.output(f_o.readlines())
|
|
||||||
c.execute("""select * from songs where songtitle like '%Come now%'""")
|
c.execute("""select * from songs where songtitle like '%Come now%'""")
|
||||||
|
|
||||||
conn.commit()
|
conn.commit()
|
||||||
#self.display.sub_output("Index SA1 created " + database);
|
|
||||||
#c.execute("""create index if not exists sa2 on songauthors (songid ASC,authorid ASC) """)
|
|
||||||
#conn.commit()
|
|
||||||
#self.display.sub_output("Index SA2 created " + database);
|
|
||||||
conn.close()
|
conn.close()
|
||||||
self.display.output("Migration 1.9.0 Finished for " + database);
|
self.display.output("Migration 1.9.0 Finished for " + database);
|
||||||
|
|
||||||
def _v1_9_0_authors(self, database):
|
def _v1_9_0_authors(self, database):
|
||||||
self.display.sub_output("Authors Started for "+database);
|
self.display.sub_output("Authors Started for "+database);
|
||||||
cmd = "sqlite3 -echo "+ self.data_path+"/"+database + ' "alter table authors add column first_name varchar(40);"'
|
conn = sqlite3.connect(self.data_path+os.sep+database)
|
||||||
self.run_cmd(cmd)
|
conn.text_factory = str
|
||||||
|
conn.execute("""alter table authors add column first_name varchar(40);""")
|
||||||
|
conn.commit()
|
||||||
self.display.sub_output("first name created")
|
self.display.sub_output("first name created")
|
||||||
cmd = "sqlite3 -echo "+ self.data_path+"/"+database + ' "alter table authors add column last_name varchar(40);"'
|
conn.execute("""alter table authors add column last_name varchar(40);""")
|
||||||
self.run_cmd(cmd)
|
conn.commit()
|
||||||
self.display.sub_output("last name created")
|
self.display.sub_output("last name created")
|
||||||
cmd = "sqlite3 -echo "+ self.data_path+"/"+database + ' "create index if not exists author1 on authors (authorname ASC,authorid ASC);"'
|
conn.execute("""create index if not exists author1 on authors (authorname ASC,authorid ASC);""")
|
||||||
self.run_cmd(cmd)
|
conn.commit()
|
||||||
self.display.sub_output("index author1 created")
|
self.display.sub_output("index author1 created")
|
||||||
cmd = "sqlite3 -echo "+ self.data_path+"/"+database + ' "create index if not exists author2 on authors (last_name ASC,authorid ASC);"'
|
conn.execute("""create index if not exists author2 on authors (last_name ASC,authorid ASC);""")
|
||||||
self.run_cmd(cmd)
|
conn.commit()
|
||||||
self.display.sub_output("index author2 created")
|
self.display.sub_output("index author2 created")
|
||||||
cmd = "sqlite3 -echo "+ self.data_path+"/"+database + ' "create index if not exists author3 on authors (first_name ASC,authorid ASC);"'
|
conn.execute("""create index if not exists author3 on authors (first_name ASC,authorid ASC);""")
|
||||||
self.run_cmd(cmd)
|
conn.commit()
|
||||||
self.display.sub_output("index author3 created")
|
self.display.sub_output("index author3 created")
|
||||||
self.display.sub_output("Author Data Migration started")
|
self.display.sub_output("Author Data Migration started")
|
||||||
conn = sqlite3.connect(self.data_path+"/"+database)
|
|
||||||
conn.text_factory = str
|
|
||||||
c = conn.cursor()
|
c = conn.cursor()
|
||||||
text = c.execute("""select * from authors """) .fetchall()
|
text = c.execute("""select * from authors """) .fetchall()
|
||||||
for author in text:
|
for author in text:
|
||||||
@ -98,34 +88,40 @@ class MigrateSongs():
|
|||||||
|
|
||||||
def _v1_9_0_topics(self, database):
|
def _v1_9_0_topics(self, database):
|
||||||
self.display.sub_output("Topics Started for "+database);
|
self.display.sub_output("Topics Started for "+database);
|
||||||
cmd = "sqlite3 -echo "+ self.data_path+"/"+database + ' "create table if not exists topics (topic_id integer Primary Key ASC AUTOINCREMENT);"'
|
conn = sqlite3.connect(self.data_path+os.sep+database)
|
||||||
self.run_cmd(cmd)
|
conn.text_factory = str
|
||||||
|
conn.execute("""create table if not exists topics (topic_id integer Primary Key ASC AUTOINCREMENT);""")
|
||||||
|
conn.commit()
|
||||||
self.display.sub_output("Topic table created")
|
self.display.sub_output("Topic table created")
|
||||||
cmd = "sqlite3 -echo "+ self.data_path+"/"+database + ' "alter table topics add column topic_name varchar(40);"'
|
conn.execute("""alter table topics add column topic_name varchar(40);""")
|
||||||
self.run_cmd(cmd)
|
conn.commit()
|
||||||
self.display.sub_output("topicname added")
|
self.display.sub_output("topicname added")
|
||||||
cmd = "sqlite3 -echo "+ self.data_path+"/"+database + ' "create index if not exists topic1 on topics (topic_name ASC,topic_id ASC);"'
|
conn.execute("""create index if not exists topic1 on topics (topic_name ASC,topic_id ASC);""")
|
||||||
self.run_cmd(cmd)
|
conn.commit()
|
||||||
|
conn.close()
|
||||||
self.display.sub_output("index topic1 created")
|
self.display.sub_output("index topic1 created")
|
||||||
|
|
||||||
self.display.sub_output("Topics Completed");
|
self.display.sub_output("Topics Completed");
|
||||||
|
|
||||||
def _v1_9_0_songbook(self, database):
|
def _v1_9_0_songbook(self, database):
|
||||||
self.display.sub_output("SongBook Started for "+database);
|
self.display.sub_output("SongBook Started for "+database);
|
||||||
cmd = "sqlite3 -echo "+ self.data_path+"/"+database + ' "create table if not exists songbook (songbook_id integer Primary Key ASC AUTOINCREMENT);"'
|
conn = sqlite3.connect(self.data_path+os.sep+database)
|
||||||
self.run_cmd(cmd)
|
conn.text_factory = str
|
||||||
|
conn.execute("""create table if not exists songbook (songbook_id integer Primary Key ASC AUTOINCREMENT);""")
|
||||||
|
conn.commit()
|
||||||
self.display.sub_output("SongBook table created")
|
self.display.sub_output("SongBook table created")
|
||||||
cmd = "sqlite3 -echo "+ self.data_path+"/"+database + ' "alter table songbook add column songbook_name varchar(40);"'
|
conn.execute("""alter table songbook add column songbook_name varchar(40);""")
|
||||||
self.run_cmd(cmd)
|
conn.commit()
|
||||||
self.display.sub_output("songbook_name added")
|
self.display.sub_output("songbook_name added")
|
||||||
cmd = "sqlite3 -echo "+ self.data_path+"/"+database + ' "alter table songbook add column songbook_publisher varchar(40);"'
|
conn.execute("""alter table songbook add column songbook_publisher varchar(40);""")
|
||||||
self.run_cmd(cmd)
|
conn.commit()
|
||||||
self.display.sub_output("songbook_publisher added")
|
self.display.sub_output("songbook_publisher added")
|
||||||
cmd = "sqlite3 -echo "+ self.data_path+"/"+database + ' "create index if not exists songbook1 on songbook (songbook_name ASC,songbook_id ASC);"'
|
conn.execute("""create index if not exists songbook1 on songbook (songbook_name ASC,songbook_id ASC);""")
|
||||||
self.run_cmd(cmd)
|
conn.commit()
|
||||||
self.display.sub_output("index songbook1 created")
|
self.display.sub_output("index songbook1 created")
|
||||||
cmd = "sqlite3 -echo "+ self.data_path+"/"+database + ' "create index if not exists songbook2 on songbook (songbook_publisher ASC,songbook_id ASC);"'
|
conn.execute("""create index if not exists songbook2 on songbook (songbook_publisher ASC,songbook_id ASC);""")
|
||||||
self.run_cmd(cmd)
|
conn.commit()
|
||||||
|
conn.close()
|
||||||
self.display.sub_output("index songbook2 created")
|
self.display.sub_output("index songbook2 created")
|
||||||
self.display.sub_output("SongBook Completed");
|
self.display.sub_output("SongBook Completed");
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user