Merge lp:~j-corwin/openlp/migration into lp:openlp

Proposed by Jonathan Corwin
Status: Superseded
Proposed branch: lp:~j-corwin/openlp/migration
Merge into: lp:openlp
Diff against target: None lines
To merge this branch: bzr merge lp:~j-corwin/openlp/migration
Reviewer Review Type Date Requested Status
Raoul Snyman Needs Fixing
Review via email: mp+6124@code.launchpad.net

This proposal has been superseded by a proposal from 2009-05-02.

To post a comment you must log in.
Revision history for this message
Jonathan Corwin (j-corwin) wrote :

Attempt to fix song migration so it matches current file definitions.
Remove the need to edit the dmp file as part of the migration

Revision history for this message
Raoul Snyman (raoul-snyman) wrote :

Muhahaha! The Style Police has arrived!

(Yes, this is mostly old code, but it needs to be said!)

All strings are single-quoted and unicode:

  self.display.output("Songs processing started")

  should be:

  self.display.output(u'Songs processing started')

Why are you adding columns one at a time?

  conn.execute("""create table authors (id integer primary key ASC AUTOINCREMENT);""")
  conn.commit()
  self.display.sub_output("authors table created")
  conn.execute("""alter table authors add column first_name varchar(128);""")
  conn.commit()
  self.display.sub_output("first_name added")
  conn.execute("""alter table authors add column last_name varchar(128);""")
  conn.commit()

  Shouldn't that rather be:

  conn.execute("""
    create table authors (
      id integer primary key ASC AUTOINCREMENT,
      first_name varchar(128),
      last_name varchar(128),
      display_name varchar(255)
    );""")
  conn.commit()
  self.display.sub_output("authors table created")

Also name variables better:

  # I'm not sure what these two variables are supposed to be
  def run_cmd(self, cmd):
      f_i, f_o = os.popen4(cmd)

review: Needs Fixing
Revision history for this message
Jonathan Corwin (j-corwin) wrote :

On Sat, May 2, 2009 at 9:31 PM, Raoul Snyman <
<email address hidden>> wrote:

> Review: Needs Fixing
> Muhahaha! The Style Police has arrived!
>
> (Yes, this is mostly old code, but it needs to be said!)
>
> All strings are single-quoted and unicode:
>
> self.display.output("Songs processing started")
>
> should be:
>
> self.display.output(u'Songs processing started')

Was already there, nowt to do with me

>
> Why are you adding columns one at a time?
>
> conn.execute("""create table authors (id integer primary key ASC
> AUTOINCREMENT);""")
> conn.commit()
> self.display.sub_output("authors table created")
> conn.execute("""alter table authors add column first_name
> varchar(128);""")
> conn.commit()
> self.display.sub_output("first_name added")
> conn.execute("""alter table authors add column last_name varchar(128);""")
> conn.commit()
>
> Shouldn't that rather be:

> conn.execute("""
> create table authors (
> id integer primary key ASC AUTOINCREMENT,
> first_name varchar(128),
> last_name varchar(128),
> display_name varchar(255)
> );""")
> conn.commit()
> self.display.sub_output("authors table created")

I agree, but again was just copying what was already there since I didn't
know if the original author had done it that way on purpose

>
> Also name variables better:
>
> # I'm not sure what these two variables are supposed to be
> def run_cmd(self, cmd):
> f_i, f_o = os.popen4(cmd)

I didn't touch this function and have no idea what it does.

All I was doing was updating existing code so it worked... I wasn't planning
on rewriting the whole existing
module.

Revision history for this message
Jonathan Corwin (j-corwin) wrote :

> Muhahaha! The Style Police has arrived!

Changes pushed.

lp:~j-corwin/openlp/migration updated
439. By Raoul Snyman

Added images

440. By Raoul Snyman

Merged Jonathan Corwin's changes to the database migration script.

441. By Tim Bentley

Start adding serviceitem code and SlideController code.
Fix some Theme bugs as well

442. By Raoul Snyman

Added slide images.

443. By Tim Bentley

Various fixes and more additions of SlideController stuff
Add ButtonBar for SlideControllers

444. By Tim Bentley

<email address hidden>

445. By Tim Bentley

<email address hidden>

446. By Tim Bentley

<email address hidden>

447. By Tim Bentley

<email address hidden>

448. By Tim Bentley

<email address hidden>

449. By Tim Bentley

<email address hidden>

450. By Tim Bentley

fix copyright symbol error

451. By Raoul Snyman

Changed the SlideController to look MUCH nicer.

452. By Tim Bentley

<email address hidden>

453. By Raoul Snyman

A number of style cleanups.

454. By Tim Bentley

Fix Cancel bug on BibleImport screen
Fix odi error on PresentationDialog

455. By Raoul Snyman

Merged config changes into trunk.

456. By Tim Bentley

<email address hidden>

457. By Tim Bentley

Fix crash

458. By Tim Bentley

<email address hidden>

459. By Raoul Snyman

Merged proposal #7122

460. By Raoul Snyman

Removed erroneous "show"ing of the display form.

461. By Tim Bentley

Fix bible bugs and make fomatting corrections

462. By Raoul Snyman

Split ServiceManager toolbar into 2 parts, resized docks to a smaller size again thanks to narrower ServiceManager.

463. By Tim Bentley

Add OOS and speed up Renderer

464. By Raoul Snyman

Pulling in QImage changes from renderer branch

465. By Tim Bentley

add OOS code and speed up renderer
Add re-theming in servicemanager when theme changes.
Sort out Renderer to prevent not relevent calls

466. By Tim Bentley

Songs plugin phase 1 complete

467. By Tim Bentley

Finish the cleanup of Songs.

468. By Tim Bentley

Mass Unicode conversion.

469. By Tim Bentley

ode cleanups from last merge and Bible Custom changes
Remove 2.6 deprication

470. By Tim Bentley

ServiceManager changes
Small bug fixes
New OOS format

471. By Tim Bentley

OOS now works with Images , Bibles, Songs and Custom
Fixes to Bible plugin and clean up of Images
Mennu fixes

472. By Tim Bentley

Change default Unicode handling

473. By Tim Bentley

Page Up/Down works on SlideController
Search for Authors on Songs now work

474. By Raoul Snyman

Merged changed keyboard events.

475. By Tim Bentley

Fix error on Song Saving

476. By Tim Bentley

Various fixes and addition of song migation code

477. By Martin Thompson

Merged media manager refactoring

478. By Raoul Snyman

Merged Andrew Lok's video tests into trunk

479. By Raoul Snyman

Merged assert fixes.

480. By Tim Bentley

Plugable slide controllers
Start of OpenOffice Plugin.
Bug fixes

481. By Tim Bentley

fixups to mediamanager
Bug fixes
Plugable Toolbar

482. By Tim Bentley

Martins mediaItem Changes
SlideController rewrite
Plugable SlideControllerBars
Bug fixes
Better Rendering size

483. By Tim Bentley

Remove unused stuff
Add more bits to ImageSlideController bar
Clean up ThemeManager
Add OOS saving

484. By Raoul Snyman

Fixed up a few logging things, a few bits of indentation, and resolved some conflicts from the last update.

485. By Raoul Snyman

Merged changes to Bible plugin into trunk.

486. By Raoul Snyman

Put the settings tab back in after accidentally removing it... silly me!

487. By Raoul Snyman

Merged docstrings changes.

488. By Raoul Snyman

Merging from docstrings branch.

489. By Tim Bentley

Cleanups
Plugin slidepreviers
documentatation
removal of old files

490. By Raoul Snyman

Removing built documentation - this is not needed, we only need to store the documentation source files in version control.

491. By Raoul Snyman

Added ignore status to directories in the documentation's build directory.

492. By Tim Bentley

Bug fixes from the wiki

493. By Tim Bentley

Various bug fixes and code improvements.

494. By Raoul Snyman

Merged in the changes from the biblefixes branch.

495. By Tim Bentley

Fix song editing so it works
Added now images for Song editors
Fix up Alert code so now works.

496. By Tim Bentley

Fix up song dialog errors
Fix servicemanager key entry
Fix servicemanager state handling

497. By Raoul Snyman

Merged in changes from the songmaintenance branch

498. By Raoul Snyman

Merged in some changes for the song maintenance form.

499. By Tim Bentley

New features and fixes.

500. By Tim Bentley

Bug fixes from last merge

501. By Raoul Snyman

Merged in changes from my song maintenance branch.

502. By Raoul Snyman

Merge from songmaintenance branch.

503. By Tim Bentley

New bible Import Screen
Transparent Theme backgrounds
Global Theme Handling improvements

-------This line and the following will be ignored --------------

modified:
  openlp/core/lib/renderer.py
  openlp/core/lib/themexmlhandler.py
  openlp/core/ui/amendthemeform.py
  openlp/core/ui/servicemanager.py
  openlp/core/ui/thememanager.py
  openlp/core/ui/themestab.py
  openlp/plugins/bibles/forms/bibleimportdialog.py
  resources/forms/bibleimportdialog.ui
pending merges:
  Tim Bentley 2009-08-07 finish Theme handling corrections
    Tim Bentley 2009-08-07 Default handling allows editing and blocks deletes
    Tim Bentley 2009-08-07 New bible import form
    Tim Bentley 2009-08-06 [merge] Head
    Tim Bentley 2009-08-06 Standardize row hight in renderer

504. By Tim Bentley

Lets save songs now

505. By Raoul Snyman

Merge from bugfixes

506. By Tim Bentley

Remote pluging
EventManager Fixes
Cleanups
Renderer Performance improvements

507. By Tim Bentley

Updates

508. By Tim Bentley

Lets put the bracket in the correct place

509. By Tim Bentley

Plugin Screen added
Presentation Plugin started
Remotes now configurable

510. By Tim Bentley

Many fixes and corrections
Adding Presentation code (start)
Add error message to code

511. By Tim Bentley

SlideController clean up
Image Plugin Cleanup

512. By Tim Bentley

Clean up Event Processing

513. By Jon Tibble

Committing Jon Tibble's merge proposal.

514. By Maikel Stuivenberg

Merged in lp:~maikels/openlp/myfixes

515. By Tim Bentley

Sort out SlideController

516. By Tim Bentley

Various changes see loog for details

517. By Jon Tibble

Merge for John

518. By Jon Tibble

Merge for Jon

519. By Tim Bentley

Performance Improvements and code fixes

520. By Raoul Snyman

Merge from lp:~raoul-snyman/openlp/songmaintenance

521. By Jon Tibble

Merged in lp:~meths/openlp/trivialfixes

522. By Tim Bentley

New features and fixes

523. By Tim Bentley

Add Next slide to Presentations
Start with settings manager

524. By Raoul Snyman

Merged lp:~raoul-snyman/openlp/docstrings into trunk.

525. By Jon Tibble

Latest merge from lp:~meths/openlp/trivialfixes

526. By Tim Bentley

Various changes

527. By Jon Tibble

For Jon

528. By Tim Bentley

Song and Custom cleanups

529. By Jon Tibble

For Jon

530. By Raoul Snyman

Merged changes in from lp:~raoul-snyman/openlp/songmaintenance

531. By Jon Tibble

Merged in lp:~meths/openlp/trivialfixes

532. By Raoul Snyman

Merged in lp:~raoul-snyman/openlp/docstrings

533. By Jon Tibble

Merged in lp:~meths/openlp/trivialfixes

534. By Jon Tibble

For Jon
Fix themes

535. By Jon Tibble

For Jon
Fix themes 2

536. By Jon Tibble

For Jon

537. By Raoul Snyman

Merge from lp:~raoul-snyman/openlp/bugfixes

538. By Tim Bentley

Updates to Presentations etc

539. By Maikel Stuivenberg

For Maikel

540. By Tim Bentley

Themes and Timer points

541. By Tim Bentley

Fix merge error

542. By Jon Tibble

For Jon

543. By Tim Bentley

Renderer handling changes

544. By Jon Tibble

Merged in lp:~meths/openlp/trivialfixes

545. By Jon Tibble

For Jon

546. By Jon Tibble

For Jon

547. By Jonathan Corwin

for jonathan

548. By Tim Bentley

presentation fixes

549. By Tim Bentley

Correction from == to is

550. By Jon Tibble

Merge log.exception() conversion

551. By Tim Bentley

Arrival of the Audit

552. By Tim Bentley

Plugin cleanup

553. By Maikel Stuivenberg

Menu changes

554. By Jon Tibble

Dock Widget Refactoring

555. By Jon Tibble

Fix service loading on Windows

556. By Tim Bentley

Audit Fixes

557. By Jon Tibble

Refactor services

558. By Jon Tibble

Cleanup code and fixes

559. By Tim Bentley

Renderer Fixes

560. By Raoul Snyman

Merged in lp:~raoul-snyman/openlp/bugfixes

561. By Tim Bentley

rendering fixes

562. By Jon Tibble

Song editor fixes

563. By Jon Tibble

Coding Standards

564. By Tim Bentley

Best merge ever

565. By Tim Bentley

Audit changes and clean up

566. By Jonathan Corwin

Merge from lp:~j-corwin/openlp/presentations

567. By Jon Tibble

Code clean ups

568. By Tim Bentley

Audit Changes to database

569. By Jonathan Corwin

Merge from lp:~j-corwin/openlp/presentations

570. By Jon Tibble

PPTViewer fixes

571. By Jon Tibble

Imports clean up

572. By Tim Bentley

Plugin changes to Audit, Song and Custom

573. By Jon Tibble

None testing and clean ups

574. By Tim Bentley

Plugin updates

575. By Jonathan Corwin

Jons Presentation merge with hack to fix conflicts

576. By Tim Bentley

Audit changes and cleanups

577. By Jonathan Corwin

Presentation merge with gotos

578. By Jon Tibble

Fix presentation starting

579. By Jon Tibble

Use buildIcon and fixes

580. By Tim Bentley

Style cleanups

581. By Jonathan Corwin

Presentations made it at last

582. By Jonathan Corwin

Presentation dll

583. By Tim Bentley

Start of about Text

584. By Jon Tibble

Dialogs, Exceptions and Toolbars

585. By Tim Bentley

Update PluginList Window

586. By Jonathan Corwin

Presentation updates

587. By Tim Bentley

Add Ability to hide plugins

588. By Jonathan Corwin

More Presentation improvements

589. By Tim Bentley

More hiding code changes

590. By Tim Bentley

Fix song issue

591. By Jon Tibble

Presentation cleanups

592. By Jon Tibble

Bible rendering fixes

593. By Tim Bentley

Apply fixes for Jon

594. By Raoul Snyman

Merged in lp:~raoul-snyman/openlp/pluginlist

595. By Tim Bentley

Plugin hinding comes to town

596. By Jonathan Corwin

More Presentation fixes

597. By Tim Bentley

Various changes and fixes

598. By Jonathan Corwin

TLC for the asv

599. By Raoul Snyman

Merged in lp:~raoul-snyman/openlp/versionfix

600. By Tim Bentley

Add Web Bibles to Advanced Tab and other nice features

601. By Jonathan Corwin

Presentation changes

602. By Tim Bentley

Update config files for deployment

603. By Jonathan Corwin

Windows/Linux sqlite2 -> sqlite3 migration in one step

604. By Jonathan Corwin

Fix code standard issues. Remove redundant modules

605. By Jonathan Corwin

Head

606. By Jonathan Corwin

Bible migration

607. By Jonathan Corwin

Head

608. By Jonathan Corwin

Bible migration

609. By Jonathan Corwin

Commit verses at end

610. By Jonathan Corwin

Head

611. By Jonathan Corwin

Commented out two lines without realising it. I blame Noah

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'openlp/migration/migratesongs.py'
--- openlp/migration/migratesongs.py 2009-02-04 20:16:56 +0000
+++ openlp/migration/migratesongs.py 2009-05-02 19:32:15 +0000
@@ -48,10 +48,10 @@
48 print self.database_files48 print self.database_files
4949
50 def process(self):50 def process(self):
51 self.display.output("Songs processing started");51 self.display.output("Songs processing started")
52 for f in self.database_files:52 for f in self.database_files:
53 self.v_1_9_0(f)53 self.v_1_9_0(f)
54 self.display.output("Songs processing finished");54 self.display.output("Songs processing finished")
5555
56 def v_1_9_0(self, database):56 def v_1_9_0(self, database):
57 self.display.output("Migration 1.9.0 Started for "+database);57 self.display.output("Migration 1.9.0 Started for "+database);
@@ -61,83 +61,69 @@
61 self._v1_9_0_songauthors(database)61 self._v1_9_0_songauthors(database)
62 self._v1_9_0_songtopics(database)62 self._v1_9_0_songtopics(database)
63 self._v1_9_0_songs(database)63 self._v1_9_0_songs(database)
64 self._v1_9_0_songs_update(database)64 self.display.output("Migration 1.9.0 Finished for " + database)
65
66 self.display.output("Migration 1.9.0 Finished for " + database);
6765
68 def _v1_9_0_authors(self, database):66 def _v1_9_0_authors(self, database):
69 self.display.sub_output("Authors Started for "+database);67 self.display.sub_output("Authors Started for "+database)
70 conn = sqlite3.connect(self.data_path+os.sep+database)68 conn = sqlite3.connect(self.data_path+os.sep+database)
71 conn.execute("""alter table authors rename to authors_temp;""")69 conn.execute("""alter table authors rename to authors_temp;""")
72 conn.commit()70 conn.commit()
7371 conn.execute("""create table authors (id integer primary key ASC AUTOINCREMENT);""")
74 conn.execute("""create table authors add column display_name varchar(255);""")
75 conn.commit()72 conn.commit()
76 self.display.sub_output("first name created")73 self.display.sub_output("authors table created")
77 conn.execute("""alter table authors add column first_name varchar(128);""")74 conn.execute("""alter table authors add column first_name varchar(128);""")
78 conn.commit()75 conn.commit()
79 self.display.sub_output("first name created")76 self.display.sub_output("first_name added")
80 conn.execute("""alter table authors add column last_name varchar(128);""")77 conn.execute("""alter table authors add column last_name varchar(128);""")
81 conn.commit()78 conn.commit()
82 self.display.sub_output("last name created")79 self.display.sub_output("last_name added")
83 conn.execute("""create index if not exists author_display_name on authors (display_name ASC,id ASC);""")80 conn.execute("""alter table authors add column display_name varchar(255);""")
81 conn.commit()
82 self.display.sub_output("display_name added")
83 conn.execute("""create index if not exists author1 on authors (display_name ASC,id ASC);""")
84 conn.commit()84 conn.commit()
85 self.display.sub_output("index author1 created")85 self.display.sub_output("index author1 created")
86 conn.execute("""create index if not exists author_last_name on authors (last_name ASC,id ASC);""")86 conn.execute("""create index if not exists author2 on authors (last_name ASC,id ASC);""")
87 conn.commit()87 conn.commit()
88 self.display.sub_output("index author2 created")88 self.display.sub_output("index author2 created")
89 conn.execute("""create index if not exists author_first_name on authors (first_name ASC,id ASC);""")89 conn.execute("""create index if not exists author3 on authors (first_name ASC,id ASC);""")
90 conn.commit()90 conn.commit()
91 self.display.sub_output("index author3 created")91 self.display.sub_output("index author3 created")
92 self.display.sub_output("Author Data Migration started")92 self.display.sub_output("Author Data Migration started")
93 c = conn.cursor()93 conn.execute("""insert into authors (id, display_name) select authorid, authorname from authors_temp;""")
94 text = c.execute("""select * from authors """) .fetchall()94 conn.commit()
95 self.display.sub_output("authors populated")
96 c = conn.cursor()
97 text = c.execute("""select * from authors""") .fetchall()
95 for author in text:98 for author in text:
96 dispname = author[1]99 dispname = author[3]
97 if author[2] == None:100 dispname = dispname.replace("'", "") # remove quotes.
98 dispname = dispname.replace("'", "") # remove quotes.101 pos = dispname.rfind(" ")
99 pos = dispname.rfind(" ")102 afn = dispname[:pos]
100 afn = dispname[:pos]103 aln = dispname[pos + 1:len(dispname)]
101 aln = dispname[pos + 1:len(dispname)]104 s = "update authors set first_name = '" \
102 #txt = text[2]105 + afn + "', last_name = '" + aln + "' where id = " + str(author[0])
103 s = "update authors set display_name = '" + dispname + "', first_name = '" + afn + "', last_name = '" + aln + "' where id = " +str(author[0])106 text1 = c.execute(s)
104 text1 = c.execute(s)107 conn.commit()
105 conn.commit()
106 conn.execute("""alter table authors drop column authorname;""")
107 conn.commit()
108 conn.close()
109 self.display.sub_output("Author Data Migration Completed")108 self.display.sub_output("Author Data Migration Completed")
110 self.display.sub_output("Authors Completed");109 conn.execute("""drop table authors_temp;""")
111
112 def _v1_9_0_topics(self, database):
113 self.display.sub_output("Topics Started for "+database);
114 conn = sqlite3.connect(self.data_path+os.sep+database)
115 conn.text_factory = str
116 conn.execute("""create table if not exists topics (id integer Primary Key ASC AUTOINCREMENT);""")
117 conn.commit()
118 self.display.sub_output("Topic table created")
119 conn.execute("""alter table topics add column name varchar(128);""")
120 conn.commit()
121 self.display.sub_output("topicname added")
122 conn.execute("""create index if not exists topic1 on topics (name ASC,id ASC);""")
123 conn.commit()110 conn.commit()
124 conn.close()111 conn.close()
125 self.display.sub_output("index topic1 created")112 self.display.sub_output("author_temp dropped")
126113 self.display.sub_output("Authors Completed")
127 self.display.sub_output("Topics Completed");
128114
129 def _v1_9_0_songbook(self, database):115 def _v1_9_0_songbook(self, database):
130 self.display.sub_output("SongBook Started for "+database);116 self.display.sub_output("SongBook Started for "+database)
131 conn = sqlite3.connect(self.data_path+os.sep+database)117 conn = sqlite3.connect(self.data_path+os.sep+database)
132 conn.execute("""create table if not exists song_books (id integer Primary Key ASC AUTOINCREMENT);""")118 conn.execute("""create table if not exists song_books (id integer Primary Key ASC AUTOINCREMENT);""")
133 conn.commit()119 conn.commit()
134 self.display.sub_output("SongBook table created")120 self.display.sub_output("SongBook table created")
135 conn.execute("""alter table song_books add column name varchar(128);""")121 conn.execute("""alter table song_books add column name varchar(128);""")
136 conn.commit()122 conn.commit()
137 self.display.sub_output("songbook_name added")123 self.display.sub_output("songbook name added")
138 conn.execute("""alter table song_books add column publisher varchar(128);""")124 conn.execute("""alter table song_books add column publisher varchar(128);""")
139 conn.commit()125 conn.commit()
140 self.display.sub_output("songbook_publisher added")126 self.display.sub_output("songbook publisher added")
141 conn.execute("""create index if not exists songbook1 on song_books (name ASC,id ASC);""")127 conn.execute("""create index if not exists songbook1 on song_books (name ASC,id ASC);""")
142 conn.commit()128 conn.commit()
143 self.display.sub_output("index songbook1 created")129 self.display.sub_output("index songbook1 created")
@@ -145,45 +131,31 @@
145 conn.commit()131 conn.commit()
146 conn.close()132 conn.close()
147 self.display.sub_output("index songbook2 created")133 self.display.sub_output("index songbook2 created")
148 self.display.sub_output("SongBook Completed");134 self.display.sub_output("SongBook Completed")
149
150 def _v1_9_0_songtopics(self, database):
151 self.display.sub_output("Songtopics Started for "+database);
152 conn = sqlite3.connect(self.data_path+os.sep+database)
153 conn.execute("""create table if not exists song_topics (song_id integer Primary Key ASC );""")
154 conn.commit()
155 self.display.sub_output("Songtopics table created")
156 conn.execute("""alter table song_topics add column topic_id interger;""")
157 conn.commit()
158 self.display.sub_output("songtopics_topic_id added")
159 conn.execute("""create index if not exists songtopic1 on song_topics (topic_id ASC,song_id ASC);""")
160 conn.commit()
161 self.display.sub_output("index songbook1 created")
162 conn.execute("""create index if not exists songbook2 on song_topics (song_id ASC,topic_id ASC);""")
163 conn.commit()
164 conn.close()
165 self.display.sub_output("index songbook2 created")
166 self.display.sub_output("SongTopics Completed");
167
168 def _v1_9_0_songauthors(self, database):
169 self.display.sub_output("SongAuthors Started for "+database);
170 conn = sqlite3.connect(self.data_path+os.sep+database)
171 conn.execute("""alter table songauthors rename to authors_songs;""")
172 conn.commit()
173 conn.close()
174 self.display.sub_output("Table Renamed")
175 self.display.sub_output("SongAuthors Completed");
176
177135
178 def _v1_9_0_songs(self, database):136 def _v1_9_0_songs(self, database):
179 self.display.sub_output("Songs Started for "+database);137 self.display.sub_output("Songs Started for "+database)
180 conn = sqlite3.connect(self.data_path+os.sep+database)138 conn = sqlite3.connect(self.data_path+os.sep+database)
181 conn.execute("""alter table songs add column song_book_id interger;""")139 conn.execute("""alter table songs rename to songs_temp;""")
182 conn.commit()140 conn.commit()
183 self.display.sub_output("songs_song_book_id added")141 conn.execute("""create table if not exists songs (id integer Primary Key ASC AUTOINCREMENT);""")
142 conn.commit()
143 self.display.sub_output("songs table created")
144 conn.execute("""alter table songs add column song_book_id integer;""")
145 conn.commit()
146 self.display.sub_output("songs song_book_id added")
147 conn.execute("""alter table songs add title varchar(255);""")
148 conn.commit()
149 self.display.sub_output("songs title added")
150 conn.execute("""alter table songs add lyrics text;""")
151 conn.commit()
152 self.display.sub_output("songs lyrics added")
184 conn.execute("""alter table songs add column verse_order varchar(128);""")153 conn.execute("""alter table songs add column verse_order varchar(128);""")
185 conn.commit()154 conn.commit()
186 self.display.sub_output("songs verse_order added")155 self.display.sub_output("songs verse_order added")
156 conn.execute("""alter table songs add copyright varchar(255);""")
157 conn.commit()
158 self.display.sub_output("songs copyright added")
187 conn.execute("""alter table songs add column comments text;""")159 conn.execute("""alter table songs add column comments text;""")
188 conn.commit()160 conn.commit()
189 self.display.sub_output("songs comments added")161 self.display.sub_output("songs comments added")
@@ -208,50 +180,75 @@
208 self.display.sub_output("index songs1 created")180 self.display.sub_output("index songs1 created")
209 conn.execute("""create index if not exists songs2 on songs (search_title ASC,id ASC);""")181 conn.execute("""create index if not exists songs2 on songs (search_title ASC,id ASC);""")
210 conn.commit()182 conn.commit()
211 conn.close()
212 self.display.sub_output("index songs2 created")183 self.display.sub_output("index songs2 created")
213 self.display.sub_output("Songs Completed");184
214185 conn.execute("""insert into songs (id, title, lyrics, copyright, search_title, search_lyrics, song_book_id)
215186 select songid, songtitle, lyrics, copyrightinfo,
216187 replace(replace(replace(replace(replace(replace(replace(replace(replace(songtitle, '&', 'and'), ',', ''), ';', ''), ':', ''), '(', ''), ')', ''), '{', ''), '}',''),'?',''),
217 def _v1_9_0_songs_update(self, database):188 replace(replace(replace(replace(replace(replace(replace(replace(replace(lyrics, '&', 'and'), ',', ''), ';', ''), ':', ''), '(', ''), ')', ''), '{', ''), '}',''),'?',''),
218 self.display.sub_output("Songs Started for "+database);189 0
219 self.db = create_engine("sqlite:///"+self.data_path+os.sep+database, encoding='utf-8' , convert_unicode=False, assert_unicode=False)190 from songs_temp;""")
220191
221 self.db.echo = True192 conn.commit()
222 metadata.bind = self.db193 self.display.sub_output("songs populated")
223 metadata.bind.echo = False194 conn.execute("""drop table songs_temp;""")
224 Session = scoped_session(sessionmaker(autoflush=True, autocommit=False))195 conn.commit()
225 Session.configure(bind=self.db)196 conn.close()
226 #create missing table197 self.display.sub_output("songs_temp dropped")
227 songs_topics_table.create()198
228 songs = Session.query(Song).all()199 self.display.sub_output("Songs Completed")
229 for song in songs:200
230 t=song.title.replace("&", "and")201 def _v1_9_0_topics(self, database):
231 t=t.replace("'", "")202 self.display.sub_output("Topics Started for "+database)
232 t=t.replace(",", "")203 conn = sqlite3.connect(self.data_path+os.sep+database)
233 t=t.replace(";", "")204 conn.text_factory = str
234 t=t.replace(":", "")205 conn.execute("""create table if not exists topics (id integer Primary Key ASC AUTOINCREMENT);""")
235 t=t.replace("(", "")206 conn.commit()
236 t=t.replace(")", "")207 self.display.sub_output("Topic table created")
237 t=t.replace("{", "")208 conn.execute("""alter table topics add column name varchar(128);""")
238 t=t.replace("}", "")209 conn.commit()
239 t=t.replace("?", "")210 self.display.sub_output("topicname added")
240 song.search_title = t211 conn.execute("""create index if not exists topic1 on topics (name ASC,id ASC);""")
241 t=song.lyrics.replace("&", "and")212 conn.commit()
242 t=t.replace("'", "")213 conn.close()
243 t=t.replace(",", "")214 self.display.sub_output("index topic1 created")
244 t=t.replace(";", "")215
245 t=t.replace(":", "")216 self.display.sub_output("Topics Completed")
246 t=t.replace("(", "")217
247 t=t.replace(")", "")218 def _v1_9_0_songauthors(self, database):
248 t=t.replace("{", "")219 self.display.sub_output("SongAuthors Started for "+database);
249 t=t.replace("}", "")220 conn = sqlite3.connect(self.data_path+os.sep+database)
250 t=t.replace("?", "")221 conn.execute("""create table if not exists authors_songs (author_id integer);""")
251 song.search_lyrics = t222 conn.commit()
252 song.song_book_id = 0223 self.display.sub_output("authors_songs table created")
253 Session.save_or_update(song)224 conn.execute("""alter table authors_songs add column song_id integer;""")
254 Session.commit()225 conn.commit()
226 conn.execute("""insert into authors_songs (author_id, song_id) select authorid, songid from songauthors;""")
227 conn.commit()
228 self.display.sub_output("authors_songs populated")
229 conn.execute("""drop table songauthors;""")
230 conn.commit()
231 self.display.sub_output("songauthors dropped")
232 conn.close()
233 self.display.sub_output("SongAuthors Completed")
234
235 def _v1_9_0_songtopics(self, database):
236 self.display.sub_output("Songtopics Started for "+database);
237 conn = sqlite3.connect(self.data_path+os.sep+database)
238 conn.execute("""create table if not exists song_topics (song_id integer);""")
239 conn.commit()
240 self.display.sub_output("Songtopics table created")
241 conn.execute("""alter table song_topics add column topic_id integer;""")
242 conn.commit()
243 self.display.sub_output("songtopics_topic_id added")
244 conn.execute("""create index if not exists songtopic1 on song_topics (topic_id ASC,song_id ASC);""")
245 conn.commit()
246 self.display.sub_output("index songtopic1 created")
247 conn.execute("""create index if not exists songtopic2 on song_topics (song_id ASC,topic_id ASC);""")
248 conn.commit()
249 conn.close()
250 self.display.sub_output("index songtopic2 created")
251 self.display.sub_output("SongTopics Completed")
255252
256 def run_cmd(self, cmd):253 def run_cmd(self, cmd):
257 f_i, f_o = os.popen4(cmd)254 f_i, f_o = os.popen4(cmd)
258255
=== modified file 'openlpcnv.pyw' (properties changed: -x to +x)