mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
Compare commits
1 commit
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
da41daa168 |
8 changed files with 18 additions and 10 deletions
|
|
@ -4,7 +4,6 @@ import collections
|
||||||
import hashlib
|
import hashlib
|
||||||
import itertools
|
import itertools
|
||||||
import os
|
import os
|
||||||
import sqlite3
|
|
||||||
import sys
|
import sys
|
||||||
import threading
|
import threading
|
||||||
import traceback
|
import traceback
|
||||||
|
|
@ -33,6 +32,7 @@ from .utils import (
|
||||||
escape_sqlite,
|
escape_sqlite,
|
||||||
get_plugins,
|
get_plugins,
|
||||||
module_from_path,
|
module_from_path,
|
||||||
|
sqlite3,
|
||||||
sqlite_timelimit,
|
sqlite_timelimit,
|
||||||
to_css_class
|
to_css_class
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,12 @@
|
||||||
import hashlib
|
import hashlib
|
||||||
import sqlite3
|
|
||||||
|
|
||||||
from .utils import detect_spatialite, detect_fts, escape_sqlite, get_all_foreign_keys
|
from .utils import (
|
||||||
|
detect_spatialite,
|
||||||
|
detect_fts,
|
||||||
|
escape_sqlite,
|
||||||
|
get_all_foreign_keys,
|
||||||
|
sqlite3
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
HASH_BLOCK_SIZE = 1024 * 1024
|
HASH_BLOCK_SIZE = 1024 * 1024
|
||||||
|
|
|
||||||
|
|
@ -9,13 +9,17 @@ import os
|
||||||
import pkg_resources
|
import pkg_resources
|
||||||
import re
|
import re
|
||||||
import shlex
|
import shlex
|
||||||
import sqlite3
|
|
||||||
import tempfile
|
import tempfile
|
||||||
import time
|
import time
|
||||||
import shutil
|
import shutil
|
||||||
import urllib
|
import urllib
|
||||||
import numbers
|
import numbers
|
||||||
|
|
||||||
|
try:
|
||||||
|
import pysqlite3 as sqlite3
|
||||||
|
except ImportError:
|
||||||
|
import sqlite3
|
||||||
|
|
||||||
# From https://www.sqlite.org/lang_keywords.html
|
# From https://www.sqlite.org/lang_keywords.html
|
||||||
reserved_words = set((
|
reserved_words = set((
|
||||||
'abort action add after all alter analyze and as asc attach autoincrement '
|
'abort action add after all alter analyze and as asc attach autoincrement '
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@ import asyncio
|
||||||
import csv
|
import csv
|
||||||
import json
|
import json
|
||||||
import re
|
import re
|
||||||
import sqlite3
|
|
||||||
import time
|
import time
|
||||||
import urllib
|
import urllib
|
||||||
|
|
||||||
|
|
@ -25,6 +24,7 @@ from datasette.utils import (
|
||||||
path_with_format,
|
path_with_format,
|
||||||
remove_infinites,
|
remove_infinites,
|
||||||
resolve_table_and_format,
|
resolve_table_and_format,
|
||||||
|
sqlite3,
|
||||||
to_css_class,
|
to_css_class,
|
||||||
value_as_boolean,
|
value_as_boolean,
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,3 @@
|
||||||
import sqlite3
|
|
||||||
import urllib
|
import urllib
|
||||||
|
|
||||||
import jinja2
|
import jinja2
|
||||||
|
|
@ -19,6 +18,7 @@ from datasette.utils import (
|
||||||
path_with_added_args,
|
path_with_added_args,
|
||||||
path_with_removed_args,
|
path_with_removed_args,
|
||||||
path_with_replaced_args,
|
path_with_replaced_args,
|
||||||
|
sqlite3,
|
||||||
to_css_class,
|
to_css_class,
|
||||||
urlsafe_components,
|
urlsafe_components,
|
||||||
value_as_boolean,
|
value_as_boolean,
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
from datasette.app import Datasette
|
from datasette.app import Datasette
|
||||||
|
from datasette.utils import sqlite3
|
||||||
import itertools
|
import itertools
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
import pytest
|
import pytest
|
||||||
import random
|
import random
|
||||||
import sqlite3
|
|
||||||
import sys
|
import sys
|
||||||
import string
|
import string
|
||||||
import tempfile
|
import tempfile
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
from datasette.app import Datasette
|
from datasette.app import Datasette
|
||||||
|
from datasette.utils import sqlite3
|
||||||
import os
|
import os
|
||||||
import pytest
|
import pytest
|
||||||
import sqlite3
|
|
||||||
import tempfile
|
import tempfile
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,6 @@ import json
|
||||||
import os
|
import os
|
||||||
import pytest
|
import pytest
|
||||||
from sanic.request import Request
|
from sanic.request import Request
|
||||||
import sqlite3
|
|
||||||
import tempfile
|
import tempfile
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
|
|
||||||
|
|
@ -228,7 +227,7 @@ def test_detect_fts():
|
||||||
CREATE VIRTUAL TABLE "Street_Tree_List_fts" USING FTS4 ("qAddress", "qCaretaker", "qSpecies", content="Street_Tree_List");
|
CREATE VIRTUAL TABLE "Street_Tree_List_fts" USING FTS4 ("qAddress", "qCaretaker", "qSpecies", content="Street_Tree_List");
|
||||||
CREATE VIRTUAL TABLE r USING rtree(a, b, c);
|
CREATE VIRTUAL TABLE r USING rtree(a, b, c);
|
||||||
'''
|
'''
|
||||||
conn = sqlite3.connect(':memory:')
|
conn = utils.sqlite3.connect(':memory:')
|
||||||
conn.executescript(sql)
|
conn.executescript(sql)
|
||||||
assert None is utils.detect_fts(conn, 'Dumb_Table')
|
assert None is utils.detect_fts(conn, 'Dumb_Table')
|
||||||
assert None is utils.detect_fts(conn, 'Test_View')
|
assert None is utils.detect_fts(conn, 'Test_View')
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue