sqlutilpy 0.23.0__tar.gz → 0.24.0__tar.gz

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.
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.2
2
2
  Name: sqlutilpy
3
- Version: 0.23.0
3
+ Version: 0.24.0
4
4
  Summary: Database query code returning numpy arrays
5
5
  Author-email: "Sergey E. Koposov" <skoposov@ed.ac.uk>
6
6
  License: BSD
@@ -339,31 +339,38 @@ def get(query,
339
339
  proc = None
340
340
  colNames = []
341
341
  if driver == 'psycopg2':
342
- warnings.warn(
343
- 'psycopg2 driver is not supported anymore using psycopg instead'
344
- )
342
+ warnings.warn('psycopg2 driver is not supported anymore. '
343
+ 'We using psycopg instead')
345
344
  driver = 'psycopg'
346
345
  if driver == 'psycopg':
347
346
  try:
348
- while (True):
347
+ while True:
349
348
  # Iterating over the cursor, retrieving batches of results
350
349
  # and then sending them for conversion
351
350
  tups = cur.fetchmany()
352
351
  desc = cur.description
353
352
 
353
+ # If the is just the start we need to launch the
354
+ # thread doing the conversion
355
+ no_results = tups == []
356
+ if nrec == 0:
357
+ typeCodes = [_tmp.type_code for _tmp in desc]
358
+ colNames = [_tmp.name for _tmp in cur.description]
359
+
354
360
  # No more data
355
- if tups == []:
361
+ if no_results:
362
+ dtype = __getDType([None] * len(typeCodes), typeCodes,
363
+ strLength)
356
364
  break
357
365
 
366
+ dtype = __getDType(tups[0], typeCodes, strLength)
367
+
358
368
  # Send the new batch for conversion
359
369
  qIn.put(tups)
360
370
 
361
371
  # If the is just the start we need to launch the
362
372
  # thread doing the conversion
363
373
  if nrec == 0:
364
- typeCodes = [_tmp.type_code for _tmp in desc]
365
- colNames = [_tmp.name for _tmp in cur.description]
366
- dtype = __getDType(tups[0], typeCodes, strLength)
367
374
  proc = threading.Thread(target=__converter,
368
375
  args=(qIn, qOut, endEvent,
369
376
  dtype, intNullVal))
@@ -731,9 +738,8 @@ table/pandas/dictionary or provide a separate list of arrays and their names')
731
738
  names = ','.join(names)
732
739
  for i in range(0, N, nsplit):
733
740
  try:
734
- with cur.copy(
735
- f'''copy {tableName}({names}) from stdin with delimiter '{delimiter}' '''
736
- ) as copy:
741
+ with cur.copy(f'''copy {tableName}({names}) from stdin
742
+ with delimiter '{delimiter}' ''') as copy:
737
743
  __print_arrays([_[i:i + nsplit] for _ in arrays],
738
744
  copy,
739
745
  delimiter=delimiter)
@@ -0,0 +1 @@
1
+ __version__ = '0.24.0'
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.2
2
2
  Name: sqlutilpy
3
- Version: 0.23.0
3
+ Version: 0.24.0
4
4
  Summary: Database query code returning numpy arrays
5
5
  Author-email: "Sergey E. Koposov" <skoposov@ed.ac.uk>
6
6
  License: BSD
@@ -255,6 +255,12 @@ def test_get_dict(setup):
255
255
  **kw)
256
256
  for i, k in enumerate(cols.split(',')):
257
257
  assert ((Rd[k] == R0[i]).all())
258
+ Rempty = sqlutil.get('select %s from sqlutil_test where sicol<-10000' %
259
+ (cols, ),
260
+ asDict=True,
261
+ **kw)
262
+ for i, k in enumerate(cols.split(',')):
263
+ assert k in Rempty
258
264
 
259
265
 
260
266
  def test_get_dict_rep(setup):
@@ -1 +0,0 @@
1
- __version__ = '0.23.0'
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes