Skip to main content

threadingpg

Control PostgreSQL using thread(s).

Initialize Controller

import threadingpg
controller = threadingpg.Controller()
controller.connect(dbname='database_name', user='user_name', password='password', port=5432)
# ...
controller.close()

Initialize Pool

import threadingpg
controller = threadingpg.Pool(dbname='database_name', user='user_name', password='password', port=5432)
# ...
controller.close()

Table and Row

Table

import threadingpg
class MyTable(threadingpg.Table):
    table_name="mytable"
    index = threadingpg.Column(data_type=threadingpg.types.serial)
    name = threadingpg.Column(data_type=threadingpg.types.varchar())
# or 
class MyTable(threadingpg.Table):
    def __init__(self) -> None:
        self.index = threadingpg.Column(data_type=threadingpg.types.serial)
        self.name = threadingpg.Column(data_type=threadingpg.types.varchar())
        super().__init__("mytable") # important position

Create/Drop Table

mytable = MyTable()
controller.create_table(mytable)
controller.drop_table(mytable)

Row

class MyRow(threadingpg.Row):
    def __init__(self, name:str=None) -> None:
        self.name = name

Insert Row

mytable = MyTable()
myrow = MyRow("my_row")
controller.insert_row(mytable, myrow)
# or
controller.insert_dict(mytable, {"name":"my_row"})

Select Row

mytable = MyTable()
column_name_list, rows = controller.select(mytable)
for row in rows:
    myrow = MyRow()
    myrow.set_data(column_name_list, row)
    print(f"output: {myrow.name}") # output: my_row

Update Row

mytable = MyTable()
myrow = MyRow("update_my_row")
condition_equal_0 = threadingpg.condition.Equal(mytable.index, 0)
controller.update_row(mytable, myrow, condition_equal_0)

Delete Row

mytable = MyTable()
delete_condition = threadingpg.condition.Equal(mytable.index, 5)
controller.delete_row(mytable, delete_condition)

Conditions

Where

mytable = MyTable()
condition_equal_1 = threadingpg.condition.Equal(mytable.index, 1)
condition_equal_2 = threadingpg.condition.Equal(mytable.index, 2)
condition_equal_3 = threadingpg.condition.Equal(mytable.index, 3)
conditions = threadingpg.condition.Or(condition_equal_1, condition_equal_2, condition_equal_3)
column_name_list, rows = controller.select(mytable, where=conditions)

OrderBy

mytable = MyTable()
orderby_index = threadingpg.condition.OrderBy(mytable.index)
orderby_name = threadingpg.condition.OrderBy(mytable.name, True)
orderby_conditions = threadingpg.condition.And(orderby_index, orderby_name)
column_name_list, rows = controller.select(mytable, order_by=orderby_conditions)

Trigger

Need delay each function.

mytable = MyTable()
channel_name = "mych"
trigger_name = "mytr"
function_name = "myfn"

listner = threadingpg.TriggerListner()
# implement 'notify = listner.notify_queue.get()'

listner.connect(dbname=dbname, user=user, password=password, port=5432)
listner.create_function(function_name, channel_name)
listner.create_trigger(mytable, trigger_name, function_name)

listner.start_listening()
listner.listen_channel(channel_name)
# ...
listner.unlisten_channel(channel_name)
listner.stop_listening()

Metadata

Release files for threadingpg 0.0.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for threadingpg 0.0.6
File Size Uploaded Provenance Actions
threadingpg-0.0.6.tar.gz 12.5 kB Without provenance Details for threadingpg-0.0.6.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for threadingpg 0.0.6
File Interpreter ABI Platform Actions
threadingpg-0.0.6-py3-none-any.whl Python 3 none any Details for threadingpg-0.0.6-py3-none-any.whl

Total release size: 25.7 kB

Release files / threadingpg-0.0.6.tar.gz

Download URL threadingpg-0.0.6.tar.gz
Size 12.5 kB
Tags Source
SHA-256 checksum
How to use checksums
0d3b45fe7b8a1dbe4ff4f811fb015856e66cbc2a11c39c02958b92d1ce707f14
BLAKE2b-256 checksum
How to use checksums
d6f3b044ee3f6f753843ff7e812a5645d1e22325d5492d9c51a0cec4a16f0145
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.8

Release files / threadingpg-0.0.6-py3-none-any.whl

Download URL threadingpg-0.0.6-py3-none-any.whl
Size 13.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f3f22d6987542c80c1308da4a7de5652ae0a7351ed7a6ae099df4a3b55589402
BLAKE2b-256 checksum
How to use checksums
9f3eb9409af915c45f664dc9b3c9e11dbcee06898de0fefb7f419195bb6e18f0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.8

Security for threadingpg 0.0.6

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page