Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to open database of udgerdb_v3.dat #10

Open
EswarRB opened this issue Feb 9, 2023 · 0 comments
Open

Unable to open database of udgerdb_v3.dat #10

EswarRB opened this issue Feb 9, 2023 · 0 comments

Comments

@EswarRB
Copy link

EswarRB commented Feb 9, 2023

from udger import Udger
import os.path
def ua_parse(user_agent):
    filepath = os.path.abspath('./udger-updater-linux/udgerdb_v3.dat')
    udger = Udger(filepath)
    result = udger.parse_ua(user_agent)
    return result
ua = 'Mozilla/5.0 (iPad; CPU OS 7_0 like Mac OS X) AppleWebKit/537.51.1 (KHTML, like Gecko) Version/7.0 Mobile/11A465 Safari/9537.53'
ua_parse(ua)
---------------------------------------------------------------------------
OperationalError                         
Traceback (most recent call last)
Cell In[15], line 9
      7     return result.user_agent.popularity_index >= 50
      8 ua = 'Mozilla/5.0 (iPad; CPU OS 7_0 like Mac OS X) AppleWebKit/537.51.1 (KHTML, like Gecko) Version/7.0 Mobile/11A465 Safari/9537.53'
----> 9 is_popular_ua(ua)

Cell In[15], line 6, in is_popular_ua(user_agent)
      4 filepath = os.path.abspath('udgerdb_v3.dat')
      5 udger = Udger(filepath)
----> 6 result = udger.parse_ua(user_agent)
      7 return result.user_agent.popularity_index >= 50

File ~./udger/parser.py:14, in Udger.parse_ua(self, ua_string)
     11     if cached is not None:
     12         return cached
---> 14 ua, class_id, client_id = self._client_detector(ua_string)
     15 is_crawler = (ua['ua_class'] == 'Crawler')
     17 opsys = self._os_detector(ua_string, client_id) if not is_crawler else None

File ~./udger/parser.py:87, in Udger._client_detector(self, ua_string)
     86 def _client_detector(self, ua_string):
---> 87     ua = self.db_get_first_row(Queries.crawler_sql, ua_string)
     88     if ua:
     89         del ua['class_id']

File ~./udger/base.py:221, in UdgerBase.db_get_first_row(self, sql, *params)
    218     def db_get_first_row(self, sql, *params):
    219 #        self.last_regexp_match = None
--> 221         self.db_cursor.execute(sql, params)
    223         for row in self.db_cursor:
    224             return row

File ~./udger/base.py:36, in cached_property.__get__(self, instance, unused_type)
     34 if instance is None:
     35     return self
---> 36 res = instance.__dict__[self.func.__name__] = self.func(instance)
     37 return res

File ~./udger/base.py:142, in UdgerBase.db_cursor(self)
    139     @cached_property
    140     def db_cursor(self):
    141         db_filepath = os.path.join(self.data_dir, self.db_filename)
--> 142         db = sqlite3.connect(db_filepath)
    143 #        db.create_function("REGEXP", 2, self.regexp_func)
    145         cursor = db.cursor()

OperationalError: unable to open database file 

Why is this happening and what can be the possible fix for this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant