Skip to content

Commit a30ac39

Browse files
committed
Fix iUtil vtable; new temp_database context manager
1 parent 9f1a315 commit a30ac39

File tree

7 files changed

+37
-12
lines changed

7 files changed

+37
-12
lines changed

docs/changelog.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22
Changelog
33
#########
44

5+
Version 1.3.2
6+
=============
7+
8+
* Fix unregistered bug: iUtil methods removed after FB 4 Beta 2 broke the Int128/TZ handling.
9+
* New context manager `.temp_database`.
10+
511
Version 1.3.1
612
=============
713

docs/conf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@
2323
author = 'Pavel Císař'
2424

2525
# The short X.Y version
26-
version = '1.3.1'
26+
version = '1.3.2'
2727

2828
# The full version, including alpha/beta/rc tags
29-
release = '1.3.1'
29+
release = '1.3.2'
3030

3131

3232
# -- General configuration ---------------------------------------------------

docs/ref-core.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ transaction
2323
-----------
2424
.. autofunction:: transaction
2525

26+
temp_database
27+
-------------
28+
.. autofunction:: temp_database
29+
2630
Functions
2731
=========
2832

firebird/driver/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
3636
3737
"""
38-
from .config import driver_config
38+
from .config import driver_config, ServerConfig, DatabaseConfig, DriverConfig
3939
from .fbapi import load_api, get_api
4040
from .types import Error, InterfaceError, DatabaseError, DataError, \
4141
OperationalError, IntegrityError, InternalError, ProgrammingError, \
@@ -54,9 +54,9 @@
5454
DESCRIPTION_SCALE, DESCRIPTION_NULL_OK, Date, Time, Timestamp, DateFromTicks, \
5555
TimeFromTicks, TimestampFromTicks, STRING, BINARY, NUMBER, DATETIME, ROWID, \
5656
get_timezone
57-
from .core import connect, create_database, connect_server, transaction, tpb, TPB, \
58-
CHARSET_MAP, DistributedTransactionManager, Connection, Cursor, \
57+
from .core import connect, create_database, connect_server, transaction, temp_database, \
58+
tpb, TPB, CHARSET_MAP, DistributedTransactionManager, Connection, Cursor, \
5959
Server, Statement
6060

6161
#: Current driver version, SEMVER string.
62-
__VERSION__ = '1.3.1'
62+
__VERSION__ = '1.3.2'

firebird/driver/core.py

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,22 @@ def transaction(transact_object: Transactional, *, tpb: bytes=None,
264264
else:
265265
transact_object.commit()
266266

267+
@contextlib.contextmanager
268+
def temp_database(*args, **kwargs) -> Connection:
269+
"""Context manager for temporary databases. Creates new database when context
270+
is entered, and drops it on exit. Exception raised in managed context is NOT suppressed.
271+
272+
All positional and keyword arguments are passed to `create_database`.
273+
"""
274+
con = create_database(*args, **kwargs)
275+
try:
276+
yield con
277+
except:
278+
con.drop_database()
279+
raise
280+
else:
281+
con.drop_database()
282+
267283
_OP_DIE = object()
268284
_OP_RECORD_AND_REREGISTER = object()
269285

@@ -3617,9 +3633,10 @@ def callproc(self, proc_name: str, parameters: Sequence=None) -> None:
36173633
.. note::
36183634
36193635
If stored procedure does have output parameters, you must retrieve their values
3620-
saparatelly by `.Cursor.fetchone()` call. This method is not very convenient, but conforms
3621-
to Python DB API 2.0. If you don't require conformance to Python DB API, it's recommended
3622-
to use more convenient method `.Cursor.call_procedure()` instead.
3636+
saparatelly by `.Cursor.fetchone()` call. This method is not very convenient,
3637+
but conforms to Python DB API 2.0. If you don't require conformance to Python
3638+
DB API, it's recommended to use more convenient method `.Cursor.call_procedure()`
3639+
instead.
36233640
"""
36243641
params = [] if parameters is None else parameters
36253642
sql = ('EXECUTE PROCEDURE ' + proc_name + ' '

firebird/driver/fbapi.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1696,8 +1696,6 @@ class IInt128_struct(Structure):
16961696
('setOffsets', IUtil_setOffsets),
16971697
('getDecFloat16', IUtil_getDecFloat16),
16981698
('getDecFloat34', IUtil_getDecFloat34),
1699-
('getTransactionByHandle', c_void_p), # FB 4 Beta 2
1700-
('getStatementByHandle', c_void_p), # FB 4 Beta 2
17011699
('decodeTimeTz', IUtil_decodeTimeTz),
17021700
('decodeTimeStampTz', IUtil_decodeTimeStampTz),
17031701
('encodeTimeTz', IUtil_encodeTimeTz),

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ all-files=True
55

66
[metadata]
77
name = firebird-driver
8-
version = 1.3.1
8+
version = 1.3.2
99
description = Firebird driver
1010
long_description = file: README.rst
1111
long_description_content_type = text/x-rst; charset=UTF-8

0 commit comments

Comments
 (0)