Skip to content

Commit 1ce3685

Browse files
committed
Upgrade pyqldb to v2.0.0
Upgraded pyqldb version from v1.0.0-rc.2 to 2.0.0 Used args for execute_statement instead of a list Added examples for native python data types
1 parent 55dcbf9 commit 1ce3685

22 files changed

+218
-169
lines changed

LICENSE

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ SPDX-License-Identifier: MIT-0
44
Permission is hereby granted, free of charge, to any person obtaining a copy of this
55
software and associated documentation files (the "Software"), to deal in the Software
66
without restriction, including without limitation the rights to use, copy, modify,
7-
erge, publish, distribute, sublicense, and/or sell copies of the Software, and to
7+
merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
88
permit persons to whom the Software is furnished to do so.
99

1010
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
11-
NCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
11+
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
1212
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
1313
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
1414
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@ $ cd docs
4747
$ make html
4848
```
4949

50+
### Release 1.0.0
51+
52+
* Upgraded pyqldb version from v1.0.0-rc.2 to 2.0.0
53+
* Used args for execute_statement instead of a list
54+
* Added examples for native python data types
55+
5056
### Release 1.0.0-rc.2 (October 29, 2019)
5157

5258
* Fixes for small documentation issues.

pyqldbsamples/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@
1414
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
1515
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1616

17-
__version__ = '1.0.0-rc.2'
17+
__version__ = '1.0.0'

pyqldbsamples/add_secondary_owner.py

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def get_document_id_by_gov_id(transaction_executor, government_id):
3131
"""
3232
Find a driver's person ID using the given government ID.
3333
34-
:type transaction_executor: :py:class:`pyqldb.session.executor.Executor`
34+
:type transaction_executor: :py:class:`pyqldb.execution.executor.Executor`
3535
:param transaction_executor: An Executor object allowing for execution of statements within a transaction.
3636
3737
:type government_id: str
@@ -48,7 +48,7 @@ def is_secondary_owner_for_vehicle(transaction_executor, vin, secondary_owner_id
4848
"""
4949
Check whether a secondary owner has already been registered for the given VIN.
5050
51-
:type transaction_executor: :py:class:`pyqldb.session.executor.Executor`
51+
:type transaction_executor: :py:class:`pyqldb.execution.executor.Executor`
5252
:param transaction_executor: An Executor object allowing for execution of statements within a transaction.
5353
5454
:type vin: str
@@ -62,8 +62,7 @@ def is_secondary_owner_for_vehicle(transaction_executor, vin, secondary_owner_id
6262
"""
6363
logger.info('Finding secondary owners for vehicle with VIN: {}...'.format(vin))
6464
query = 'SELECT Owners.SecondaryOwners FROM VehicleRegistration AS v WHERE v.VIN = ?'
65-
parameters = [convert_object_to_ion(vin)]
66-
rows = transaction_executor.execute_statement(query, parameters)
65+
rows = transaction_executor.execute_statement(query, convert_object_to_ion(vin))
6766

6867
for row in rows:
6968
secondary_owners = row.get('SecondaryOwners')
@@ -73,23 +72,25 @@ def is_secondary_owner_for_vehicle(transaction_executor, vin, secondary_owner_id
7372
return False
7473

7574

76-
def add_secondary_owner_for_vin(transaction_executor, vin, parameters):
75+
def add_secondary_owner_for_vin(transaction_executor, vin, parameter):
7776
"""
7877
Add a secondary owner into `VehicleRegistration` table for a particular VIN.
7978
80-
:type transaction_executor: :py:class:`pyqldb.session.executor.Executor`
79+
:type transaction_executor: :py:class:`pyqldb.execution.executor.Executor`
8180
:param transaction_executor: An Executor object allowing for execution of statements within a transaction.
8281
8382
:type vin: str
8483
:param vin: VIN of the vehicle to add a secondary owner for.
8584
86-
:type parameters: list
87-
:param parameters: list of parameters in Ion format.
85+
:type parameter: :py:class:`amazon.ion.simple_types.IonPyValue`
86+
:param parameter: The Ion value or Python native type that is convertible to Ion for filling in parameters of the
87+
statement.
8888
"""
8989
logger.info('Inserting secondary owner for vehicle with VIN: {}...'.format(vin))
90-
statement = "FROM VehicleRegistration AS v WHERE v.VIN = '{}' INSERT INTO v.Owners.SecondaryOwners VALUE ?".format(vin)
90+
statement = "FROM VehicleRegistration AS v WHERE v.VIN = '{}' INSERT INTO v.Owners.SecondaryOwners VALUE ?"\
91+
.format(vin)
9192

92-
cursor = transaction_executor.execute_statement(statement, parameters)
93+
cursor = transaction_executor.execute_statement(statement, parameter)
9394
logger.info('VehicleRegistration Document IDs which had secondary owners added: ')
9495
print_result(cursor)
9596

@@ -98,7 +99,7 @@ def register_secondary_owner(transaction_executor, vin, gov_id):
9899
"""
99100
Register a secondary owner for a vehicle if they are not already registered.
100101
101-
:type transaction_executor: :py:class:`pyqldb.session.executor.Executor`
102+
:type transaction_executor: :py:class:`pyqldb.execution.executor.Executor`
102103
:param transaction_executor: An Executor object allowing for execution of statements within a transaction.
103104
104105
:type vin: str
@@ -114,7 +115,7 @@ def register_secondary_owner(transaction_executor, vin, gov_id):
114115
if is_secondary_owner_for_vehicle(transaction_executor, vin, document_id):
115116
logger.info('Person with ID {} has already been added as a secondary owner of this vehicle.'.format(gov_id))
116117
else:
117-
add_secondary_owner_for_vin(transaction_executor, vin, [to_ion_struct('PersonId', document_id)])
118+
add_secondary_owner_for_vin(transaction_executor, vin, to_ion_struct('PersonId', document_id))
118119

119120

120121
if __name__ == '__main__':

pyqldbsamples/connect_to_ledger.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def create_qldb_driver(ledger_name=Constants.LEDGER_NAME, region_name=None, endp
4646
:rtype: :py:class:`pyqldb.driver.pooled_qldb_driver.PooledQldbDriver`
4747
:return: A pooled QLDB driver object.
4848
49-
[1] https://boto3.amazonaws.com/v1/documentation/api/latest/reference/core/session.html#boto3.session.Session.client
49+
[1]: `Boto3 Session.client Reference <https://boto3.amazonaws.com/v1/documentation/api/latest/reference/core/session.html#boto3.session.Session.client>`.
5050
"""
5151
qldb_driver = PooledQldbDriver(ledger_name=ledger_name, region_name=region_name, endpoint_url=endpoint_url,
5252
boto3_session=boto3_session)

pyqldbsamples/create_index.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def create_index(transaction_executor, table_name, index_attribute):
2929
"""
3030
Create an index for a particular table.
3131
32-
:type transaction_executor: :py:class:`pyqldb.session.executor.Executor`
32+
:type transaction_executor: :py:class:`pyqldb.execution.executor.Executor`
3333
:param transaction_executor: An Executor object allowing for execution of statements within a transaction.
3434
3535
:type table_name: str

pyqldbsamples/create_table.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def create_table(transaction_executor, table_name):
2929
"""
3030
Create a table with the specified name using an Executor object.
3131
32-
:type transaction_executor: :py:class:`pyqldb.session.executor.Executor`
32+
:type transaction_executor: :py:class:`pyqldb.execution.executor.Executor`
3333
:param transaction_executor: An Executor object allowing for execution of statements within a transaction.
3434
3535
:type table_name: str

pyqldbsamples/deregister_drivers_license.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,15 @@ def deregister_drivers_license(transaction_executor, license_number):
2929
"""
3030
De-register a driver's license with the given license number.
3131
32-
:type transaction_executor: :py:class:`pyqldb.session.executor.Executor`
32+
:type transaction_executor: :py:class:`pyqldb.execution.executor.Executor`
3333
:param transaction_executor: An Executor object allowing for execution of statements within a transaction.
3434
3535
:type license_number: str
3636
:param license_number: The license number of the driver's license to de-register.
3737
"""
3838
logger.info('De-registering license with license number: {}.'.format(license_number))
3939
statement = 'DELETE FROM DriversLicense AS d WHERE d.LicenseNumber = ?'
40-
parameter = [convert_object_to_ion(license_number)]
40+
parameter = convert_object_to_ion(license_number)
4141
cursor = transaction_executor.execute_statement(statement, parameter)
4242

4343
try:

pyqldbsamples/find_vehicles.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def find_vehicles_for_owner(transaction_executor, gov_id):
3030
"""
3131
Find vehicles registered under a driver using their government ID.
3232
33-
:type transaction_executor: :py:class:`pyqldb.session.executor.Executor`
33+
:type transaction_executor: :py:class:`pyqldb.execution.executor.Executor`
3434
:param transaction_executor: An Executor object allowing for execution of statements within a transaction.
3535
3636
:type gov_id: str
@@ -42,7 +42,7 @@ def find_vehicles_for_owner(transaction_executor, gov_id):
4242
"ON Vehicle.VIN = r.VIN WHERE r.Owners.PrimaryOwner.PersonId = ?"
4343

4444
for ids in document_ids:
45-
cursor = transaction_executor.execute_statement(query, [ids])
45+
cursor = transaction_executor.execute_statement(query, ids)
4646
logger.info('List of Vehicles for owner with GovId: {}...'.format(gov_id))
4747
print_result(cursor)
4848

pyqldbsamples/insert_document.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def insert_documents(transaction_executor, table_name, documents):
5050
"""
5151
Insert the given list of documents into a table in a single transaction.
5252
53-
:type transaction_executor: :py:class:`pyqldb.session.executor.Executor`
53+
:type transaction_executor: :py:class:`pyqldb.execution.executor.Executor`
5454
:param transaction_executor: An Executor object allowing for execution of statements within a transaction.
5555
5656
:type table_name: str
@@ -64,7 +64,7 @@ def insert_documents(transaction_executor, table_name, documents):
6464
"""
6565
logger.info('Inserting some documents in the {} table...'.format(table_name))
6666
statement = 'INSERT INTO {} ?'.format(table_name)
67-
cursor = transaction_executor.execute_statement(statement, [convert_object_to_ion(documents)])
67+
cursor = transaction_executor.execute_statement(statement, convert_object_to_ion(documents))
6868
list_of_document_ids = get_document_ids_from_dml_results(cursor)
6969

7070
return list_of_document_ids
@@ -74,7 +74,7 @@ def update_and_insert_documents(transaction_executor):
7474
"""
7575
Handle the insertion of documents and updating PersonIds all in a single transaction.
7676
77-
:type transaction_executor: :py:class:`pyqldb.session.executor.Executor`
77+
:type transaction_executor: :py:class:`pyqldb.execution.executor.Executor`
7878
:param transaction_executor: An Executor object allowing for execution of statements within a transaction.
7979
"""
8080
list_ids = insert_documents(transaction_executor, Constants.PERSON_TABLE_NAME, SampleData.PERSON)

0 commit comments

Comments
 (0)