jupyter-duckdb 0.9.2.3__py3-none-any.whl → 0.9.2.5__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,6 +5,7 @@ from uuid import uuid4
5
5
 
6
6
  import psycopg
7
7
 
8
+ from .util import strip_delimiters
8
9
  from ... import DatabaseError, Column, Constraint, ForeignKey, Table
9
10
  from ...Connection import Connection as Base
10
11
  from ...error import EmptyResultError
@@ -194,9 +195,10 @@ class Connection(Base):
194
195
  if match is None:
195
196
  raise AssertionError(f'could not parse foreign key definitions for table {source_table_name}')
196
197
 
197
- source_table_column_names = [c.strip() for c in match.group(1).split(',')]
198
- target_table_name = match.group(2).strip()
199
- target_table_column_names = [c.strip() for c in match.group(3).split(',')]
198
+ source_table_name = strip_delimiters(source_table_name)
199
+ source_table_column_names = [strip_delimiters(c) for c in match.group(1).split(',')]
200
+ target_table_name = strip_delimiters(match.group(2))
201
+ target_table_column_names = [strip_delimiters(c) for c in match.group(3).split(',')]
200
202
 
201
203
  # get tables
202
204
  if source_table_name not in tables:
@@ -0,0 +1,14 @@
1
+ _delimiters = ('"', "'")
2
+
3
+
4
+ def strip_delimiters(value: str):
5
+ while True:
6
+ value = value.strip()
7
+
8
+ if len(value) == 0:
9
+ return value
10
+
11
+ if value[0] != value[-1] or value[0] not in _delimiters:
12
+ return value
13
+
14
+ value = value[1:-1]
duckdb_kernel/kernel.py CHANGED
@@ -13,7 +13,7 @@ from .db.error import *
13
13
  from .magics import *
14
14
  from .parser import RAParser, DCParser
15
15
  from .util.ResultSetComparator import ResultSetComparator
16
- from .util.formatting import row_count, rows_table, wrap_image, null_str
16
+ from .util.formatting import row_count, rows_table, wrap_image
17
17
  from .visualization import *
18
18
 
19
19
 
@@ -92,7 +92,8 @@ class DuckDBKernel(Kernel):
92
92
  # we want to use the postgres driver.
93
93
  if path.startswith(('postgresql://', 'postgres://', 'pgsql://', 'psql://', 'pg://')):
94
94
  # pull data from connection string
95
- match = re.fullmatch(r'(postgresql|postgres|pgsql|psql|pg)://((.*?)(:(.*?))?@)?(.*?)(:(\d+))?(/(.*))?', path)
95
+ re_expr = r'(postgresql|postgres|pgsql|psql|pg)://((.*?)(:(.*?))?@)?(.*?)(:(\d+))?(/(.*))?'
96
+ match = re.fullmatch(re_expr, path)
96
97
 
97
98
  host = match.group(6)
98
99
  port = int(match.group(8)) if match.group(8) is not None else 5432
@@ -227,7 +228,7 @@ class DuckDBKernel(Kernel):
227
228
  if self._load_database(path):
228
229
  if not silent:
229
230
  # self.print(f'loaded database "{path}"\n')
230
- self.print(str(self._db))
231
+ self.print(str(self._db) + '\n')
231
232
 
232
233
  # copy data from source database
233
234
  if of is not None:
@@ -246,11 +247,17 @@ class DuckDBKernel(Kernel):
246
247
  if not self._db.multiple_statements_per_query():
247
248
  statements = re.split(r';\r?\n', content)
248
249
  for statement in statements:
249
- self._db.execute(statement)
250
+ try:
251
+ self._db.execute(statement)
252
+ except EmptyResultError:
253
+ pass
250
254
 
251
255
  # Other DBMS can execute multiple statements at a time.
252
256
  else:
253
- self._db.execute(content)
257
+ try:
258
+ self._db.execute(content)
259
+ except EmptyResultError:
260
+ pass
254
261
 
255
262
  if not silent:
256
263
  self.print(f'executed "{of}"\n')
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: jupyter-duckdb
3
- Version: 0.9.2.3
3
+ Version: 0.9.2.5
4
4
  Summary: a basic wrapper kernel for DuckDB
5
5
  Home-page: https://github.com/erictroebs/jupyter-duckdb
6
6
  Author: Eric Tröbs
@@ -1,7 +1,7 @@
1
1
  duckdb_kernel/__init__.py,sha256=6auU6zeJrsA4fxPSr2PYamS8fG-SMXTn5YQFXF2cseo,33
2
2
  duckdb_kernel/__main__.py,sha256=Z3GwHEBWoQjNm2Y84ijnbA0Lk66L7nsFREuqhZ_ptk0,165
3
3
  duckdb_kernel/kernel.json,sha256=_7E8Ci2FSdCvnzCjsOaue8QE8AvpS5JLQuxORO5IGtA,127
4
- duckdb_kernel/kernel.py,sha256=XjRN0_lPQvGFGJ8r8ZveAu09fLXG2IArIXZvU0-DUqs,18393
4
+ duckdb_kernel/kernel.py,sha256=wGHvQRhCu6aHvIRPQYJwb9PfRTYju4kYGx5yIeBsPvw,18666
5
5
  duckdb_kernel/db/Column.py,sha256=M9VRAaQ0uEWxZMaXjfFyjaDPpHsLuTSlvGaI5NDo6sM,516
6
6
  duckdb_kernel/db/Connection.py,sha256=5pH-CwGh-r9Q2QwJKGSxvoINBU-sqmvZyG4Q1digfeE,599
7
7
  duckdb_kernel/db/Constraint.py,sha256=1YgUHk7s8mHCVedbcuJKyXDykj7_ybbwT3Dk9p2VMis,287
@@ -13,8 +13,9 @@ duckdb_kernel/db/error/EmptyResultError.py,sha256=N9Oxi2HDZBKaRQsfRsWpJJGOYX4Bjd
13
13
  duckdb_kernel/db/error/__init__.py,sha256=oHfhfbcfyTJ3pAPN835omdQcebvJTauuULFx5gm9rq4,47
14
14
  duckdb_kernel/db/implementation/duckdb/Connection.py,sha256=CUpfIv5OVnKv82MsMVB_QEWrxlIDkNGcqxpSpRc9MQU,6086
15
15
  duckdb_kernel/db/implementation/duckdb/__init__.py,sha256=HKogB1es4wOiQUoh7_eT32xnUFLmzoCyR_0LuY9r8YQ,35
16
- duckdb_kernel/db/implementation/postgres/Connection.py,sha256=ztfDIZH34X1XauGATqRNfcKZ81_r-SPfOiPmEgcaOyw,8605
16
+ duckdb_kernel/db/implementation/postgres/Connection.py,sha256=JB5zPMBwt-iySMIeLi1WIvRB0jRckHDUhWw7GtKnndA,8738
17
17
  duckdb_kernel/db/implementation/postgres/__init__.py,sha256=HKogB1es4wOiQUoh7_eT32xnUFLmzoCyR_0LuY9r8YQ,35
18
+ duckdb_kernel/db/implementation/postgres/util.py,sha256=4nr1mqXhlwkMVXbJSfJ7dRlUm6UskpvgKApe7GRwmBI,281
18
19
  duckdb_kernel/db/implementation/sqlite/Connection.py,sha256=S-cyRlYP0nzITza5yIedXNPMJTM4Z5uY2CP1RPVaycE,6822
19
20
  duckdb_kernel/db/implementation/sqlite/__init__.py,sha256=HKogB1es4wOiQUoh7_eT32xnUFLmzoCyR_0LuY9r8YQ,35
20
21
  duckdb_kernel/magics/MagicCommand.py,sha256=OoQ6j4cNtIYjaK4MPVzJyv1eYTNu4_a7qoRx-5G3Hg0,2346
@@ -74,7 +75,7 @@ duckdb_kernel/visualization/Drawer.py,sha256=D0LkiGMvuJ2v6cQSg_axLTGaM4VXAJEQJAy
74
75
  duckdb_kernel/visualization/RATreeDrawer.py,sha256=j-Vy1zpYMzwZ3CsphyfPW-J7ou9a9tM6aXXgAlQTgDI,2128
75
76
  duckdb_kernel/visualization/SchemaDrawer.py,sha256=fkp7tnyfzKQBXVI6X7efAvT8lczi_XlA7Hc_rhP_47s,2955
76
77
  duckdb_kernel/visualization/__init__.py,sha256=5eMJmxJ01XAXcgWDn3t70eSZF2PGaXdNo6GK-x-0H3s,78
77
- jupyter_duckdb-0.9.2.3.dist-info/METADATA,sha256=bNaTQa_rguAVOoSbK3pWKwq4I2hbBDzZXSARO1yg9p8,7748
78
- jupyter_duckdb-0.9.2.3.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
79
- jupyter_duckdb-0.9.2.3.dist-info/top_level.txt,sha256=KvRRPMnmkQNuhyBsXoPmwyt26LRDp0O-0HN6u0Dm5jA,14
80
- jupyter_duckdb-0.9.2.3.dist-info/RECORD,,
78
+ jupyter_duckdb-0.9.2.5.dist-info/METADATA,sha256=bKmADNZ499mCqEeOktQpoPT4hXv4p91zo9bL4k4zxjQ,7748
79
+ jupyter_duckdb-0.9.2.5.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
80
+ jupyter_duckdb-0.9.2.5.dist-info/top_level.txt,sha256=KvRRPMnmkQNuhyBsXoPmwyt26LRDp0O-0HN6u0Dm5jA,14
81
+ jupyter_duckdb-0.9.2.5.dist-info/RECORD,,