Skip to content

Commit b832c2e

Browse files
committed
Change autocommit=True by default; release v0.3.0
1 parent 75d679e commit b832c2e

File tree

10 files changed

+68
-15
lines changed

10 files changed

+68
-15
lines changed

docs/src/whatsnew.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ What's New
44

55
This document outlines features and improvements from each release.
66

7+
v0.3.0 - September 9, 2022
8+
--------------------------
9+
* Changed autocommit=True by default
10+
711
v0.2.0 - Pre-Release
812
--------------------
913
* Changed to pure Python driver

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[metadata]
22
name = singlestoredb
3-
version = 0.2.0
3+
version = 0.3.0
44
description = Interface to the SingleStore database and cluster management APIs
55
long_description = file: README.md
66
long_description_content_type = text/markdown

singlestoredb/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"""
1515
from __future__ import annotations
1616

17-
__version__ = '0.2.0'
17+
__version__ = '0.3.0'
1818

1919
from .config import options, get_option, set_option, describe_option
2020
from .connection import connect, apilevel, threadsafety, paramstyle

singlestoredb/config.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,12 @@
136136
environ='SINGLESTOREDB_SSO_BROWSER',
137137
)
138138

139+
register_option(
140+
'autocommit', 'bool', check_bool, True,
141+
'Enable autocommits',
142+
environ='SINGLESTOREDB_AUTOCOMMIT',
143+
)
144+
139145
#
140146
# Query results options
141147
#

singlestoredb/connection.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1109,6 +1109,7 @@ def connect(
11091109
converters: Optional[Dict[int, Callable[..., Any]]] = None,
11101110
results_format: Optional[str] = None,
11111111
credential_type: Optional[str] = None,
1112+
autocommit: Optional[bool] = None,
11121113
) -> Connection:
11131114
"""
11141115
Return a SingleStoreDB connection.
@@ -1156,6 +1157,8 @@ def connect(
11561157
Format of query results: tuple, namedtuple, dict, or dataframe
11571158
credential_type : str, optional
11581159
Type of authentication to use: auth.PASSWORD, auth.JWT, or auth.BROWSER_SSO
1160+
autocommit : bool, optional
1161+
Enable autocommits
11591162
11601163
Examples
11611164
--------

singlestoredb/drivers/pymysql.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
from .base import Driver
1313
from ..converters import converters as convs
1414

15-
1615
converters: Dict[Any, Callable[..., Any]] = dict(convs)
1716
converters.update(encoders)
1817

singlestoredb/drivers/pyodbc.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,5 +59,9 @@ def remap_params(self, params: Dict[str, Any]) -> Dict[str, Any]:
5959

6060
return out
6161

62+
def after_connect(self, conn: Any, params: Dict[str, Any]) -> None:
63+
if params.get('autocommit'):
64+
conn.autocommit(True)
65+
6266
def is_connected(self, conn: Any, reconnect: bool = False) -> bool:
6367
return not conn.closed

singlestoredb/tests/test.sql

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,21 @@ COMMIT;
4141
CREATE TABLE IF NOT EXISTS alltypes (
4242
`id` INT(11),
4343
`tinyint` TINYINT,
44+
`unsigned_tinyint` TINYINT UNSIGNED,
4445
`bool` BOOL,
4546
`boolean` BOOLEAN,
4647
`smallint` SMALLINT,
48+
`unsigned_smallint` SMALLINT UNSIGNED,
4749
`mediumint` MEDIUMINT,
50+
`unsigned_mediumint` MEDIUMINT UNSIGNED,
4851
`int24` MEDIUMINT,
52+
`unsigned_int24` MEDIUMINT UNSIGNED,
4953
`int` INT,
54+
`unsigned_int` INT UNSIGNED,
5055
`integer` INTEGER,
56+
`unsigned_integer` INTEGER UNSIGNED,
5157
`bigint` BIGINT,
58+
`unsigned_bigint` BIGINT UNSIGNED,
5259
`float` FLOAT,
5360
`double` DOUBLE,
5461
`real` REAL,
@@ -88,14 +95,21 @@ COLLATE='utf8_unicode_ci';
8895
INSERT INTO alltypes SET
8996
`id`=0,
9097
`tinyint`=80,
98+
`unsigned_tinyint`=85,
9199
`bool`=0,
92100
`boolean`=1,
93101
`smallint`=-27897,
102+
`unsigned_smallint`=27897,
94103
`mediumint`=104729,
104+
`unsigned_mediumint`=120999,
95105
`int24`=-200899,
106+
`unsigned_int24`=407709,
96107
`int`=-1295369311,
108+
`unsigned_int`=3872362332,
97109
`integer`=-1741727421,
110+
`unsigned_integer`=3198387363,
98111
`bigint`=-266883847,
112+
`unsigned_bigint`=980007287362,
99113
`float`=-146486683.754744,
100114
`double`=-474646154.719356,
101115
`real`=-901409776.279346,
@@ -158,7 +172,6 @@ INSERT INTO alltypes SET
158172
`char_100`=NULL,
159173
`binary_100`=NULL,
160174
`varchar_200`=NULL,
161-
`varbinary_200`=NULL,
162175
`longtext`=NULL,
163176
`mediumtext`=NULL,
164177
`text`=NULL,

singlestoredb/tests/test_basics.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -587,11 +587,11 @@ def otype(x):
587587

588588
# Same as above
589589
if self.driver == 'pyodbc':
590-
assert row['time'] == datetime.time(0, 7, 0), row['time']
590+
assert row['time_6'] == datetime.time(0, 7, 0), row['time_6']
591591
else:
592592
assert row['time_6'] == datetime.timedelta(
593593
hours=1, minutes=10, microseconds=2,
594-
), row['time']
594+
), row['time_6']
595595
assert typ['time_6'] == 11, typ['time_6']
596596

597597
assert row['datetime'] == datetime.datetime(
@@ -602,7 +602,7 @@ def otype(x):
602602
assert row['datetime_6'] == datetime.datetime(
603603
1756, 10, 29, 2, 2, 42, 8,
604604
), row['datetime_6']
605-
assert typ['datetime'] == 12, typ['datetime']
605+
assert typ['datetime_6'] == 12, typ['datetime_6']
606606

607607
assert row['timestamp'] == datetime.datetime(
608608
1980, 12, 31, 1, 10, 23,

singlestoredb/tests/test_connection.py

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -586,6 +586,9 @@ def otype(x):
586586
assert row['tinyint'] == 80, row['tinyint']
587587
assert typ['tinyint'] == otype(1), typ['tinyint']
588588

589+
assert row['unsigned_tinyint'] == 85, row['unsigned_tinyint']
590+
assert typ['unsigned_tinyint'] == otype(1), typ['unsigned_tinyint']
591+
589592
assert row['bool'] == 0, row['bool']
590593
assert typ['bool'] == otype(1), typ['bool']
591594

@@ -595,21 +598,39 @@ def otype(x):
595598
assert row['smallint'] == -27897, row['smallint']
596599
assert typ['smallint'] == otype(2), typ['smallint']
597600

601+
assert row['unsigned_smallint'] == 27897, row['unsigned_smallint']
602+
assert typ['unsigned_smallint'] == otype(2), typ['unsigned_smallint']
603+
598604
assert row['mediumint'] == 104729, row['mediumint']
599605
assert typ['mediumint'] == otype(9), typ['mediumint']
600606

607+
assert row['unsigned_mediumint'] == 120999, row['unsigned_mediumint']
608+
assert typ['unsigned_mediumint'] == otype(9), typ['unsigned_mediumint']
609+
601610
assert row['int24'] == -200899, row['int24']
602611
assert typ['int24'] == otype(9), typ['int24']
603612

613+
assert row['unsigned_int24'] == 407709, row['unsigned_int24']
614+
assert typ['unsigned_int24'] == otype(9), typ['unsigned_int24']
615+
604616
assert row['int'] == -1295369311, row['int']
605617
assert typ['int'] == otype(3), typ['int']
606618

619+
assert row['unsigned_int'] == 3872362332, row['unsigned_int']
620+
assert typ['unsigned_int'] == otype(3), typ['unsigned_int']
621+
607622
assert row['integer'] == -1741727421, row['integer']
608623
assert typ['integer'] == otype(3), typ['integer']
609624

625+
assert row['unsigned_integer'] == 3198387363, row['unsigned_integer']
626+
assert typ['unsigned_integer'] == otype(3), typ['unsigned_integer']
627+
610628
assert row['bigint'] == -266883847, row['bigint']
611629
assert typ['bigint'] == otype(8), typ['bigint']
612630

631+
assert row['unsigned_bigint'] == 980007287362, row['unsigned_bigint']
632+
assert typ['unsigned_bigint'] == otype(8), typ['unsigned_bigint']
633+
613634
assert row['float'] == -146487000.0, row['float']
614635
assert typ['float'] == otype(4), typ['float']
615636

@@ -658,7 +679,7 @@ def otype(x):
658679
assert row['datetime_6'] == datetime.datetime(
659680
1756, 10, 29, 2, 2, 42, 8,
660681
), row['datetime_6']
661-
assert typ['datetime'] == 12, typ['datetime']
682+
assert typ['datetime_6'] == 12, typ['datetime_6']
662683

663684
assert row['timestamp'] == datetime.datetime(
664685
1980, 12, 31, 1, 10, 23,
@@ -1455,13 +1476,16 @@ def upper(x):
14551476

14561477
def test_results_format(self):
14571478
columns = [
1458-
'id', 'tinyint', 'bool', 'boolean', 'smallint', 'mediumint',
1459-
'int24', 'int', 'integer', 'bigint', 'float', 'double', 'real',
1460-
'decimal', 'dec', 'fixed', 'numeric', 'date', 'time', 'time_6',
1461-
'datetime', 'datetime_6', 'timestamp', 'timestamp_6', 'year',
1462-
'char_100', 'binary_100', 'varchar_200', 'varbinary_200',
1463-
'longtext', 'mediumtext', 'text', 'tinytext', 'longblob',
1464-
'mediumblob', 'blob', 'tinyblob', 'json', 'enum', 'set', 'bit',
1479+
'id', 'tinyint', 'unsigned_tinyint', 'bool', 'boolean',
1480+
'smallint', 'unsigned_smallint', 'mediumint', 'unsigned_mediumint',
1481+
'int24', 'unsigned_int24', 'int', 'unsigned_int',
1482+
'integer', 'unsigned_integer', 'bigint', 'unsigned_bigint',
1483+
'float', 'double', 'real', 'decimal', 'dec', 'fixed', 'numeric',
1484+
'date', 'time', 'time_6', 'datetime', 'datetime_6', 'timestamp',
1485+
'timestamp_6', 'year', 'char_100', 'binary_100', 'varchar_200',
1486+
'varbinary_200', 'longtext', 'mediumtext', 'text', 'tinytext',
1487+
'longblob', 'mediumblob', 'blob', 'tinyblob', 'json', 'enum',
1488+
'set', 'bit',
14651489
]
14661490

14671491
with s2.connect(database=type(self).dbname, results_format='tuple') as conn:

0 commit comments

Comments
 (0)