string_to_ipa icon indicating copy to clipboard operation
string_to_ipa copied to clipboard

SQLite3 DB refuses new connections

Open seydar opened this issue 2 years ago • 6 comments

When running #to_ipa on multiple words, it fails when opening the 247th/248th DB connection (tested on two machines: Apple 2015 MacBook Pro gets 247, and Apple MacBook Pro M1 gets 248). It also has issues retrieving results from the database, where sometimes it simply is an empty string when done in sequence.

It looks like this is because a new database connection is being opened up for every StringToIpa object. I recommend shifting the instance variable @database to a class variable @@database to resolve this.

seydar avatar Aug 02 '22 17:08 seydar

I have submitted a PR that fixes this here: https://github.com/hilarysk/string_to_ipa/pull/8 (original https://github.com/seydar/string_to_ipa).

Please let me know if there's anything I can do to help make my PR more amenable! I'm super grateful for this project and think it fills an important niche, so I'd love to keep it going.

seydar avatar Aug 02 '22 17:08 seydar

As an example, here is the error I get (running https://paste.tomsmeding.com/S5Bd8NTm):

/Users/ari/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/sqlite3-1.4.4/lib/sqlite3/database.rb:90:in `open_v2': unable to open database file (SQLite3::CantOpenException)
	from /Users/ari/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/sqlite3-1.4.4/lib/sqlite3/database.rb:90:in `initialize'
	from /Users/ari/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/string_to_ipa-0.1.4/lib/string_to_ipa.rb:76:in `new'
	from /Users/ari/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/string_to_ipa-0.1.4/lib/string_to_ipa.rb:76:in `database'
	from /Users/ari/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/string_to_ipa-0.1.4/lib/string_to_ipa.rb:17:in `to_ipa'
	from /Users/ari/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/string_to_ipa-0.1.4/lib/string_to_ipa.rb:89:in `to_ipa'
	from rhyme.rb:70:in `block in ipa'
	from rhyme.rb:70:in `map'
	from rhyme.rb:70:in `ipa'
	from rhyme.rb:116:in `correlate_synonyms'
	from rhyme.rb:148:in `family_rhyme'
	from rhyme.rb:159:in `<main>'

(Admittedly, I did add three debugging lines to my string_to_ipa.rb in order to verify the bug, so the line numbers here will be off by 3.)

seydar avatar Aug 02 '22 18:08 seydar

@seydar Hello! This deeply fell off my radar :/ It's apparent to me now that I don't have the capacity to properly maintain this gem, and as I'm not using it in an active project, I'm also not in a great position to realize when it needs updates in the first place. If you're still utilizing it (or a fork of it), would you have any interest in taking it over?

hilarysk avatar Feb 01 '24 04:02 hilarysk

I'd love to! What do I need to do to facilitate that trade?

seydar avatar Feb 05 '24 21:02 seydar

Great question - I don't actually know 😅 I just invited you as a collaborator to the repo, and am hoping it's just that easy ... it's a likely first step, at least, and hopefully we can figure it out from there.

hilarysk avatar Feb 09 '24 05:02 hilarysk

Got it! Thank you for your work on this!

seydar avatar Feb 09 '24 13:02 seydar