singlestoredb 1.0.4__cp38-abi3-win_amd64.whl → 1.1.0__cp38-abi3-win_amd64.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.

Potentially problematic release.


This version of singlestoredb might be problematic. Click here for more details.

@@ -29,12 +29,28 @@ from .cursors import (
29
29
  DictCursorSV,
30
30
  NamedtupleCursor,
31
31
  NamedtupleCursorSV,
32
+ ArrowCursor,
33
+ ArrowCursorSV,
34
+ NumpyCursor,
35
+ NumpyCursorSV,
36
+ PandasCursor,
37
+ PandasCursorSV,
38
+ PolarsCursor,
39
+ PolarsCursorSV,
32
40
  SSCursor,
33
41
  SSCursorSV,
34
42
  SSDictCursor,
35
43
  SSDictCursorSV,
36
44
  SSNamedtupleCursor,
37
45
  SSNamedtupleCursorSV,
46
+ SSArrowCursor,
47
+ SSArrowCursorSV,
48
+ SSNumpyCursor,
49
+ SSNumpyCursorSV,
50
+ SSPandasCursor,
51
+ SSPandasCursorSV,
52
+ SSPolarsCursor,
53
+ SSPolarsCursorSV,
38
54
  )
39
55
  from .optionfile import Parser
40
56
  from .protocol import (
@@ -443,6 +459,14 @@ class Connection(BaseConnection):
443
459
  self.cursorclass = DictCursor
444
460
  elif 'namedtuple' in self.results_type:
445
461
  self.cursorclass = NamedtupleCursor
462
+ elif 'numpy' in self.results_type:
463
+ self.cursorclass = NumpyCursor
464
+ elif 'arrow' in self.results_type:
465
+ self.cursorclass = ArrowCursor
466
+ elif 'pandas' in self.results_type:
467
+ self.cursorclass = PandasCursor
468
+ elif 'polars' in self.results_type:
469
+ self.cursorclass = PolarsCursor
446
470
  else:
447
471
  self.cursorclass = Cursor
448
472
  else:
@@ -450,6 +474,14 @@ class Connection(BaseConnection):
450
474
  self.cursorclass = SSDictCursor
451
475
  elif 'namedtuple' in self.results_type:
452
476
  self.cursorclass = SSNamedtupleCursor
477
+ elif 'numpy' in self.results_type:
478
+ self.cursorclass = SSNumpyCursor
479
+ elif 'arrow' in self.results_type:
480
+ self.cursorclass = SSArrowCursor
481
+ elif 'pandas' in self.results_type:
482
+ self.cursorclass = SSPandasCursor
483
+ elif 'polars' in self.results_type:
484
+ self.cursorclass = SSPolarsCursor
453
485
  else:
454
486
  self.cursorclass = SSCursor
455
487
 
@@ -487,6 +519,30 @@ class Connection(BaseConnection):
487
519
  elif self.cursorclass is SSNamedtupleCursor:
488
520
  self.cursorclass = SSNamedtupleCursorSV
489
521
  self.results_type = 'namedtuples'
522
+ elif self.cursorclass is NumpyCursor:
523
+ self.cursorclass = NumpyCursorSV
524
+ self.results_type = 'numpy'
525
+ elif self.cursorclass is SSNumpyCursor:
526
+ self.cursorclass = SSNumpyCursorSV
527
+ self.results_type = 'numpy'
528
+ elif self.cursorclass is ArrowCursor:
529
+ self.cursorclass = ArrowCursorSV
530
+ self.results_type = 'arrow'
531
+ elif self.cursorclass is SSArrowCursor:
532
+ self.cursorclass = SSArrowCursorSV
533
+ self.results_type = 'arrow'
534
+ elif self.cursorclass is PandasCursor:
535
+ self.cursorclass = PandasCursorSV
536
+ self.results_type = 'pandas'
537
+ elif self.cursorclass is SSPandasCursor:
538
+ self.cursorclass = SSPandasCursorSV
539
+ self.results_type = 'pandas'
540
+ elif self.cursorclass is PolarsCursor:
541
+ self.cursorclass = PolarsCursorSV
542
+ self.results_type = 'polars'
543
+ elif self.cursorclass is SSPolarsCursor:
544
+ self.cursorclass = SSPolarsCursorSV
545
+ self.results_type = 'polars'
490
546
 
491
547
  self._result = None
492
548
  self._affected_rows = 0
@@ -498,9 +554,22 @@ class Connection(BaseConnection):
498
554
  if conv is None:
499
555
  conv = converters.conversions
500
556
 
557
+ conv = conv.copy()
558
+
501
559
  self.parse_json = parse_json
502
560
  self.invalid_values = (invalid_values or {}).copy()
503
561
 
562
+ # Disable JSON parsing for Arrow
563
+ if self.results_type in ['arrow']:
564
+ conv[245] = None
565
+ self.parse_json = False
566
+
567
+ # Disable date/time parsing for polars; let polars do the parsing
568
+ elif self.results_type in ['polars']:
569
+ conv[7] = None
570
+ conv[10] = None
571
+ conv[12] = None
572
+
504
573
  # Need for MySQLdb compatibility.
505
574
  self.encoders = {k: v for (k, v) in conv.items() if type(k) is not int}
506
575
  self.decoders = {k: v for (k, v) in conv.items() if type(k) is int}
@@ -4,7 +4,9 @@ from collections import namedtuple
4
4
 
5
5
  from . import err
6
6
  from ..connection import Cursor as BaseCursor
7
+ from ..utils import results
7
8
  from ..utils.debug import log_query
9
+ from ..utils.results import get_schema
8
10
 
9
11
 
10
12
  #: Regular expression for :meth:`Cursor.executemany`.
@@ -45,6 +47,7 @@ class Cursor(BaseCursor):
45
47
  self._connection = connection
46
48
  self.warning_count = 0
47
49
  self._description = None
50
+ self._format_schema = None
48
51
  self._rownumber = 0
49
52
  self.rowcount = -1
50
53
  self.arraysize = 1
@@ -62,6 +65,10 @@ class Cursor(BaseCursor):
62
65
  def description(self):
63
66
  return self._description
64
67
 
68
+ @property
69
+ def _schema(self):
70
+ return self._format_schema
71
+
65
72
  @property
66
73
  def connection(self):
67
74
  return self._connection
@@ -394,6 +401,7 @@ class Cursor(BaseCursor):
394
401
  self.rowcount = 0
395
402
  self.warning_count = 0
396
403
  self._description = None
404
+ self._format_schema = None
397
405
  self.lastrowid = None
398
406
  self._rows = None
399
407
 
@@ -409,6 +417,10 @@ class Cursor(BaseCursor):
409
417
  if self.rowcount == 18446744073709551615:
410
418
  self.rowcount = -1
411
419
  self._description = result.description
420
+ self._format_schema = get_schema(
421
+ self.connection._results_type,
422
+ result.description,
423
+ )
412
424
  self.lastrowid = result.insert_id
413
425
  self._rows = result.rows
414
426
 
@@ -440,6 +452,134 @@ class CursorSV(Cursor):
440
452
  """Cursor class for C extension."""
441
453
 
442
454
 
455
+ class ArrowCursorMixin:
456
+ """Fetch methods for Arrow Tables."""
457
+
458
+ def fetchone(self):
459
+ return results.results_to_arrow(
460
+ self.description, super().fetchone(), single=True, schema=self._schema,
461
+ )
462
+
463
+ def fetchall(self):
464
+ return results.results_to_arrow(
465
+ self.description, super().fetchall(), schema=self._schema,
466
+ )
467
+
468
+ def fetchall_unbuffered(self):
469
+ return results.results_to_arrow(
470
+ self.description, super().fetchall_unbuffered(), schema=self._schema,
471
+ )
472
+
473
+ def fetchmany(self, size=None):
474
+ return results.results_to_arrow(
475
+ self.description, super().fetchmany(size), schema=self._schema,
476
+ )
477
+
478
+
479
+ class ArrowCursor(ArrowCursorMixin, Cursor):
480
+ """A cursor which returns results as an Arrow Table."""
481
+
482
+
483
+ class ArrowCursorSV(ArrowCursorMixin, CursorSV):
484
+ """A cursor which returns results as an Arrow Table for C extension."""
485
+
486
+
487
+ class NumpyCursorMixin:
488
+ """Fetch methods for numpy arrays."""
489
+
490
+ def fetchone(self):
491
+ return results.results_to_numpy(
492
+ self.description, super().fetchone(), single=True, schema=self._schema,
493
+ )
494
+
495
+ def fetchall(self):
496
+ return results.results_to_numpy(
497
+ self.description, super().fetchall(), schema=self._schema,
498
+ )
499
+
500
+ def fetchall_unbuffered(self):
501
+ return results.results_to_numpy(
502
+ self.description, super().fetchall_unbuffered(), schema=self._schema,
503
+ )
504
+
505
+ def fetchmany(self, size=None):
506
+ return results.results_to_numpy(
507
+ self.description, super().fetchmany(size), schema=self._schema,
508
+ )
509
+
510
+
511
+ class NumpyCursor(NumpyCursorMixin, Cursor):
512
+ """A cursor which returns results as a numpy array."""
513
+
514
+
515
+ class NumpyCursorSV(NumpyCursorMixin, CursorSV):
516
+ """A cursor which returns results as a numpy array for C extension."""
517
+
518
+
519
+ class PandasCursorMixin:
520
+ """Fetch methods for pandas DataFrames."""
521
+
522
+ def fetchone(self):
523
+ return results.results_to_pandas(
524
+ self.description, super().fetchone(), single=True, schema=self._schema,
525
+ )
526
+
527
+ def fetchall(self):
528
+ return results.results_to_pandas(
529
+ self.description, super().fetchall(), schema=self._schema,
530
+ )
531
+
532
+ def fetchall_unbuffered(self):
533
+ return results.results_to_pandas(
534
+ self.description, super().fetchall_unbuffered(), schema=self._schema,
535
+ )
536
+
537
+ def fetchmany(self, size=None):
538
+ return results.results_to_pandas(
539
+ self.description, super().fetchmany(size), schema=self._schema,
540
+ )
541
+
542
+
543
+ class PandasCursor(PandasCursorMixin, Cursor):
544
+ """A cursor which returns results as a pandas DataFrame."""
545
+
546
+
547
+ class PandasCursorSV(PandasCursorMixin, CursorSV):
548
+ """A cursor which returns results as a pandas DataFrame for C extension."""
549
+
550
+
551
+ class PolarsCursorMixin:
552
+ """Fetch methods for polars DataFrames."""
553
+
554
+ def fetchone(self):
555
+ return results.results_to_polars(
556
+ self.description, super().fetchone(), single=True, schema=self._schema,
557
+ )
558
+
559
+ def fetchall(self):
560
+ return results.results_to_polars(
561
+ self.description, super().fetchall(), schema=self._schema,
562
+ )
563
+
564
+ def fetchall_unbuffered(self):
565
+ return results.results_to_polars(
566
+ self.description, super().fetchall_unbuffered(), schema=self._schema,
567
+ )
568
+
569
+ def fetchmany(self, size=None):
570
+ return results.results_to_polars(
571
+ self.description, super().fetchmany(size), schema=self._schema,
572
+ )
573
+
574
+
575
+ class PolarsCursor(PolarsCursorMixin, Cursor):
576
+ """A cursor which returns results as a polars DataFrame."""
577
+
578
+
579
+ class PolarsCursorSV(PolarsCursorMixin, CursorSV):
580
+ """A cursor which returns results as a polars DataFrame for C extension."""
581
+
582
+
443
583
  class DictCursorMixin:
444
584
  # You can override this to use OrderedDict or other dict-like types.
445
585
  dict_type = dict
@@ -698,16 +838,48 @@ class SSCursorSV(SSCursor):
698
838
 
699
839
 
700
840
  class SSDictCursor(DictCursorMixin, SSCursor):
701
- """An unbuffered cursor, which returns results as a dictionary"""
841
+ """An unbuffered cursor, which returns results as a dictionary."""
702
842
 
703
843
 
704
844
  class SSDictCursorSV(SSCursorSV):
705
- """An unbuffered cursor for the C extension, which returns a dictionary"""
845
+ """An unbuffered cursor for the C extension, which returns a dictionary."""
706
846
 
707
847
 
708
848
  class SSNamedtupleCursor(NamedtupleCursorMixin, SSCursor):
709
- """An unbuffered cursor, which returns results as a named tuple"""
849
+ """An unbuffered cursor, which returns results as a named tuple."""
710
850
 
711
851
 
712
852
  class SSNamedtupleCursorSV(SSCursorSV):
713
- """An unbuffered cursor for the C extension, which returns results as a named tuple"""
853
+ """An unbuffered cursor for the C extension, which returns results as named tuple."""
854
+
855
+
856
+ class SSArrowCursor(ArrowCursorMixin, SSCursor):
857
+ """An unbuffered cursor, which returns results as an Arrow Table."""
858
+
859
+
860
+ class SSArrowCursorSV(ArrowCursorMixin, SSCursorSV):
861
+ """An unbuffered cursor, which returns results as an Arrow Table (accelerated)."""
862
+
863
+
864
+ class SSNumpyCursor(NumpyCursorMixin, SSCursor):
865
+ """An unbuffered cursor, which returns results as a numpy array."""
866
+
867
+
868
+ class SSNumpyCursorSV(NumpyCursorMixin, SSCursorSV):
869
+ """An unbuffered cursor, which returns results as a numpy array (accelerated)."""
870
+
871
+
872
+ class SSPandasCursor(PandasCursorMixin, SSCursor):
873
+ """An unbuffered cursor, which returns results as a pandas DataFrame."""
874
+
875
+
876
+ class SSPandasCursorSV(PandasCursorMixin, SSCursorSV):
877
+ """An unbuffered cursor, which returns results as a pandas DataFrame (accelerated)."""
878
+
879
+
880
+ class SSPolarsCursor(PolarsCursorMixin, SSCursor):
881
+ """An unbuffered cursor, which returns results as a polars DataFrame."""
882
+
883
+
884
+ class SSPolarsCursorSV(PolarsCursorMixin, SSCursorSV):
885
+ """An unbuffered cursor, which returns results as a polars DataFrame (accelerated)."""
@@ -363,6 +363,216 @@ INSERT INTO alltypes SET
363
363
  ;
364
364
 
365
365
 
366
+ CREATE TABLE IF NOT EXISTS alltypes_no_nulls (
367
+ `id` INT(11) NOT NULL,
368
+ `tinyint` TINYINT NOT NULL,
369
+ `unsigned_tinyint` TINYINT UNSIGNED NOT NULL,
370
+ `bool` BOOL NOT NULL,
371
+ `boolean` BOOLEAN NOT NULL,
372
+ `smallint` SMALLINT NOT NULL,
373
+ `unsigned_smallint` SMALLINT UNSIGNED NOT NULL,
374
+ `mediumint` MEDIUMINT NOT NULL,
375
+ `unsigned_mediumint` MEDIUMINT UNSIGNED NOT NULL,
376
+ `int24` MEDIUMINT NOT NULL,
377
+ `unsigned_int24` MEDIUMINT UNSIGNED NOT NULL,
378
+ `int` INT NOT NULL,
379
+ `unsigned_int` INT UNSIGNED NOT NULL,
380
+ `integer` INTEGER NOT NULL,
381
+ `unsigned_integer` INTEGER UNSIGNED NOT NULL,
382
+ `bigint` BIGINT NOT NULL,
383
+ `unsigned_bigint` BIGINT UNSIGNED NOT NULL,
384
+ `float` FLOAT NOT NULL,
385
+ `double` DOUBLE NOT NULL,
386
+ `real` REAL NOT NULL,
387
+ `decimal` DECIMAL(20,6) NOT NULL,
388
+ `dec` DEC(20,6) NOT NULL,
389
+ `fixed` FIXED(20,6) NOT NULL,
390
+ `numeric` NUMERIC(20,6) NOT NULL,
391
+ `date` DATE NOT NULL,
392
+ `time` TIME NOT NULL,
393
+ `time_6` TIME(6) NOT NULL,
394
+ `datetime` DATETIME NOT NULL,
395
+ `datetime_6` DATETIME(6) NOT NULL,
396
+ `timestamp` TIMESTAMP NOT NULL,
397
+ `timestamp_6` TIMESTAMP(6) NOT NULL,
398
+ `year` YEAR NOT NULL,
399
+ `char_100` CHAR(100) NOT NULL,
400
+ `binary_100` BINARY(100) NOT NULL,
401
+ `varchar_200` VARCHAR(200) NOT NULL,
402
+ `varbinary_200` VARBINARY(200) NOT NULL,
403
+ `longtext` LONGTEXT NOT NULL,
404
+ `mediumtext` MEDIUMTEXT NOT NULL,
405
+ `text` TEXT NOT NULL,
406
+ `tinytext` TINYTEXT NOT NULL,
407
+ `longblob` LONGBLOB NOT NULL,
408
+ `mediumblob` MEDIUMBLOB NOT NULL,
409
+ `blob` BLOB NOT NULL,
410
+ `tinyblob` TINYBLOB NOT NULL,
411
+ `json` JSON NOT NULL,
412
+ -- `geographypoint` GEOGRAPHYPOINT NOT NULL,
413
+ -- `geography` GEOGRAPHY NOT NULL,
414
+ `enum` ENUM('one', 'two', 'three') NOT NULL,
415
+ `set` SET('one', 'two', 'three') NOT NULL,
416
+ `bit` BIT NOT NULL
417
+ )
418
+ COLLATE='utf8_unicode_ci';
419
+
420
+ INSERT INTO alltypes_no_nulls SET
421
+ `id`=0,
422
+ `tinyint`=80,
423
+ `unsigned_tinyint`=85,
424
+ `bool`=0,
425
+ `boolean`=1,
426
+ `smallint`=-27897,
427
+ `unsigned_smallint`=27897,
428
+ `mediumint`=104729,
429
+ `unsigned_mediumint`=120999,
430
+ `int24`=-200899,
431
+ `unsigned_int24`=407709,
432
+ `int`=-1295369311,
433
+ `unsigned_int`=3872362332,
434
+ `integer`=-1741727421,
435
+ `unsigned_integer`=3198387363,
436
+ `bigint`=-266883847,
437
+ `unsigned_bigint`=980007287362,
438
+ `float`=-146486683.754744,
439
+ `double`=-474646154.719356,
440
+ `real`=-901409776.279346,
441
+ `decimal`=28111097.610822,
442
+ `dec`=389451155.931428,
443
+ `fixed`=-143773416.044092,
444
+ `numeric`=866689461.300046,
445
+ `date`='8524-11-10',
446
+ `time`='00:07:00',
447
+ `time_6`='01:10:00.000002',
448
+ `datetime`='9948-03-11 15:29:22',
449
+ `datetime_6`='1756-10-29 02:02:42.000008',
450
+ `timestamp`='1980-12-31 01:10:23',
451
+ `timestamp_6`='1991-01-02 22:15:10.000006',
452
+ `year`=1923,
453
+ `char_100`='This is a test of a 100 character column.',
454
+ `binary_100`=x'000102030405060708090A0B0C0D0E0F',
455
+ `varchar_200`='This is a test of a variable character column.',
456
+ `varbinary_200`=x'000102030405060708090A0B0C0D0E0F000102030405060708090A0B0C0D0E0F',
457
+ `longtext`='This is a longtext column.',
458
+ `mediumtext`='This is a mediumtext column.',
459
+ `text`='This is a text column.',
460
+ `tinytext`='This is a tinytext column.',
461
+ `longblob`=x'000102030405060708090A0B0C0D0E0F000102030405060708090A0B0C0D0E0F000102030405060708090A0B0C0D0E0F',
462
+ `mediumblob`=x'000102030405060708090A0B0C0D0E0F000102030405060708090A0B0C0D0E0F',
463
+ `blob`=x'000102030405060708090A0B0C0D0E0F',
464
+ `tinyblob`=x'0A0B0C0D0E0F',
465
+ `json`='{"a": 10, "b": 2.75, "c": "hello world"}',
466
+ `enum`='one',
467
+ `set`='two',
468
+ `bit`=128
469
+ ;
470
+
471
+ -- Minimum values
472
+ INSERT INTO alltypes_no_nulls SET
473
+ `id`=2,
474
+ `tinyint`=-128,
475
+ `unsigned_tinyint`=0,
476
+ `bool`=-128,
477
+ `boolean`=-128,
478
+ `smallint`=-32768,
479
+ `unsigned_smallint`=0,
480
+ `mediumint`=-8388608,
481
+ `unsigned_mediumint`=0,
482
+ `int24`=-8388608,
483
+ `unsigned_int24`=0,
484
+ `int`=-2147483648,
485
+ `unsigned_int`=0,
486
+ `integer`=-2147483648,
487
+ `unsigned_integer`=0,
488
+ `bigint`=-9223372036854775808,
489
+ `unsigned_bigint`=0,
490
+ `float`=0,
491
+ `double`=-1.7976931348623158e308,
492
+ `real`=-1.7976931348623158e308,
493
+ `decimal`=-99999999999999.999999,
494
+ `dec`=-99999999999999.999999,
495
+ `fixed`=-99999999999999.999999,
496
+ `numeric`=-99999999999999.999999,
497
+ `date`='1000-01-01',
498
+ `time`='-838:59:59',
499
+ `time_6`='-838:59:59.000000',
500
+ `datetime`='1000-01-01 00:00:00',
501
+ `datetime_6`='1000-01-01 00:00:00.000000',
502
+ `timestamp`='1970-01-01 00:00:01',
503
+ `timestamp_6`='1970-01-01 00:00:01.000000',
504
+ `year`=1901,
505
+ `char_100`='',
506
+ `binary_100`=x'',
507
+ `varchar_200`='',
508
+ `varbinary_200`=x'',
509
+ `longtext`='',
510
+ `mediumtext`='',
511
+ `text`='',
512
+ `tinytext`='',
513
+ `longblob`=x'',
514
+ `mediumblob`=x'',
515
+ `blob`=x'',
516
+ `tinyblob`=x'',
517
+ `json`='{}',
518
+ `enum`='one',
519
+ `set`='two',
520
+ `bit`=0
521
+ ;
522
+
523
+ -- Maximum values
524
+ INSERT INTO alltypes_no_nulls SET
525
+ `id`=3,
526
+ `tinyint`=127,
527
+ `unsigned_tinyint`=255,
528
+ `bool`=127,
529
+ `boolean`=127,
530
+ `smallint`=32767,
531
+ `unsigned_smallint`=65535,
532
+ `mediumint`=8388607,
533
+ `unsigned_mediumint`=16777215,
534
+ `int24`=8388607,
535
+ `unsigned_int24`=16777215,
536
+ `int`=2147483647,
537
+ `unsigned_int`=4294967295,
538
+ `integer`=2147483647,
539
+ `unsigned_integer`=4294967295,
540
+ `bigint`=9223372036854775807,
541
+ `unsigned_bigint`=18446744073709551615,
542
+ `float`=0,
543
+ `double`=1.7976931348623158e308,
544
+ `real`=1.7976931348623158e308,
545
+ `decimal`=99999999999999.999999,
546
+ `dec`=99999999999999.999999,
547
+ `fixed`=99999999999999.999999,
548
+ `numeric`=99999999999999.999999,
549
+ `date`='9999-12-31',
550
+ `time`='838:59:59',
551
+ `time_6`='838:59:59.999999',
552
+ `datetime`='9999-12-31 23:59:59',
553
+ `datetime_6`='9999-12-31 23:59:59.999999',
554
+ `timestamp`='2038-01-18 21:14:07',
555
+ `timestamp_6`='2038-01-18 21:14:07.999999',
556
+ `year`=2155,
557
+ `char_100`='',
558
+ `binary_100`=x'',
559
+ `varchar_200`='',
560
+ `varbinary_200`=x'',
561
+ `longtext`='',
562
+ `mediumtext`='',
563
+ `text`='',
564
+ `tinytext`='',
565
+ `longblob`=x'',
566
+ `mediumblob`=x'',
567
+ `blob`=x'',
568
+ `tinyblob`=x'',
569
+ `json`='{}',
570
+ `enum`='one',
571
+ `set`='two',
572
+ `bit`=18446744073709551615
573
+ ;
574
+
575
+
366
576
  --
367
577
  -- Table of extended data types
368
578
  --