Skip to content

Commit

Permalink
Merge pull request #1380 from ranaroussi/fix/old-sqlite-error
Browse files Browse the repository at this point in the history
Allow using sqlite3 < 3.8.2
  • Loading branch information
ValueRaider authored Jan 31, 2023
2 parents 3e964d5 + 464b333 commit 27a721c
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion yfinance/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -813,7 +813,14 @@ def __init__(self, filename):
with self._cache_mutex:
self.conn = _sqlite3.connect(filename, timeout=10, check_same_thread=False)
self.conn.execute('pragma journal_mode=wal')
self.conn.execute('create table if not exists "kv" (key TEXT primary key, value TEXT) without rowid')
try:
self.conn.execute('create table if not exists "kv" (key TEXT primary key, value TEXT) without rowid')
except Exception as e:
if 'near "without": syntax error' in str(e):
# "without rowid" requires sqlite 3.8.2. Older versions will raise exception
self.conn.execute('create table if not exists "kv" (key TEXT primary key, value TEXT)')
else:
raise
self.conn.commit()
_atexit.register(self.close)

Expand Down

0 comments on commit 27a721c

Please sign in to comment.