Skip to content

Commit 7aa8e38

Browse files
committed
Remove sqlean.py from requires
1 parent 74395ea commit 7aa8e38

4 files changed

Lines changed: 23 additions & 4 deletions

File tree

pydynamodb/superset_dynamodb/querydb_sqlite.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,29 @@
11
# -*- coding: utf-8 -*-
22
import logging
3-
import sqlean as sqlite3
43
from datetime import datetime, date
54
from contextlib import closing
65
from typing import Any, Type
76

7+
# Try to import sqlean first, fall back to native sqlite3
8+
try:
9+
import sqlean as sqlite3
10+
11+
_SQLEAN_INSTALLED = True
12+
except ImportError:
13+
import sqlite3
14+
15+
_SQLEAN_INSTALLED = False
16+
817
from .querydb import QueryDB, QueryDBConfig
918
from ..model import Statement
1019

1120
_logger = logging.getLogger(__name__) # type: ignore
1221

1322

23+
def has_sqlean() -> bool:
24+
return _SQLEAN_INSTALLED
25+
26+
1427
class SqliteFileQueryDB(QueryDB):
1528
def __init__(
1629
self,
@@ -24,7 +37,10 @@ def __init__(
2437
@property
2538
def connection(self):
2639
if self._connection is None:
27-
sqlite3.extensions.enable("math", "regexp", "stats", "text")
40+
# Enable extensions only if sqlean is available
41+
if _SQLEAN_INSTALLED:
42+
sqlite3.extensions.enable("math", "regexp", "stats", "text")
43+
2844
self._connection = sqlite3.connect(
2945
self.config.db_url,
3046
detect_types=sqlite3.PARSE_DECLTYPES | sqlite3.PARSE_COLNAMES,

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ boto3>=1.21.0
22
botocore>=1.24.7
33
tenacity>=4.1.0
44
pyparsing>=3.0.0
5-
sqlean.py>=3.45.0
5+
# sqlean.py>=3.45.0 # Optional: install for enhanced SQLite functionality

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@
1414
"botocore>=1.24.7",
1515
"tenacity>=4.1.0",
1616
"pyparsing>=3.0.0",
17-
"sqlean.py>=3.45.0",
1817
]
1918

2019
extras_require = {
2120
"sqlalchemy": ["sqlalchemy>=1.0.0"],
21+
"sqlean": ["sqlean.py>=3.45.0"],
2222
}
2323

2424
setup(

tests/test_superset_dynamodb.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33
import sqlite3
44
from typing import Any, Type
55

6+
import pytest
67
from sqlalchemy.sql import text
78
from pydynamodb.superset_dynamodb.querydb import QueryDB, QueryDBConfig
9+
from pydynamodb.superset_dynamodb.querydb_sqlite import has_sqlean
810
from pydynamodb.model import Statement
911

1012
TESTCASE04_TABLE = "pydynamodb_test_case04"
@@ -303,6 +305,7 @@ def test_string_functions_select_2(self, superset_cursor):
303305
assert len(ret) == 2
304306
assert ret[0] == ("F", "f_2", "F-2", "f-2", "2")
305307

308+
@pytest.mark.skipif(not has_sqlean(), reason="sqlean not available")
306309
def test_sqlean_string_functions(self, superset_cursor):
307310
superset_cursor.execute(
308311
"""

0 commit comments

Comments
 (0)