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

lib.db: handle numeric passwords and OrderedDict lists #684

Merged
merged 1 commit into from
Oct 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 14 additions & 9 deletions lib/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import threading
import collections
import re
from typing import OrderedDict


class Database():
Expand Down Expand Up @@ -173,16 +174,20 @@ def __init__(self, name, dbapi, connect, formatting='named'):
connect = [p.strip() for p in connect.split('|')]

# Deprecated, remove with 1.7 or 1.8
# -> but keep list of ordered dict as "default" returned by yaml parser!
if type(connect) is list:
for arg in connect:
key, sep, value = arg.partition(':')
for t in int, float, str:
try:
v = t(value)
break
except:
pass
self._params[key] = v
if isinstance(connect[0], str):
for arg in connect:
key, sep, value = arg.partition(':')
for t in int, float, str:
try:
v = t(value)
break
except:
pass
self._params[key] = v
elif isinstance(connect[0], OrderedDict):
self._params = {k: str(v) for item in connect for k, v in item.items()}

elif type(connect) in [dict, collections.OrderedDict]:
self._params = connect
Expand Down
Loading