Saravanan666/pypi-org huggingface dataset:
Package: pg-upsert
pg_upsertCheck data in a staging table or set of staging tables, then interactively update and insert (upsert) rows of a base table or base tables from the staging table(s) of the same name. Initial table checks include not-null, primary key, and foreign key checks. If any of these checks fail, the program will exit with an error message. If all checks pass, the program will display the number of rows to be inserted and updated, and ask for confirmation before proceeding. If the user confirms, the program will perform the upserts and display the number of rows inserted and updated. If the user does not confirm, the program will exit without performing any upserts.InstallationCreate a virtual environmentpython-mvenv.venvActivate the virtual environmentsource.venv/bin/activateInstall the packagepipinstallpg_upsertUsageCLIusage:pg_upsert.py[-h][-q][-d][-lLOGFILE][-eEXCLUDE_COLUMNS][-nNULL_COLUMNS][-c][-i][-mMETHOD]HOSTDATABASEUSERSTAGING_SCHEMABASE_SCHEMATABLE[TABLE...]Updateandinsert(upsert)datafromstagingtablestobasetables.

positionalarguments:HOSTdatabasehostDATABASEdatabasenameUSERdatabaseuserSTAGING_SCHEMAstagingschemanameBASE_SCHEMAbaseschemanameTABLEtablename(s)options:-h,--helpshowthishelpmessageandexit-q,--quietsuppressallconsoleoutput-d,--debugdisplaydebugoutput-lLOGFILE,--logLOGFILEwritelogtoLOGFILE-eEXCLUDE_COLUMNS,--excludeEXCLUDE_COLUMNScomma-separatedlistofcolumnstoexcludefromnullchecks-nNULL_COLUMNS,--nullNULL_COLUMNScomma-separatedlistofcolumnstoexcludefromnullchecks-c,--commitcommitchangestodatabase-i,--interactivedisplayinteractiveGUIofimportanttableinformation-mMETHOD,--methodMETHODmethodtouseforupsertPythonimportloggingfrompathlibimportPathfrompg_upsertimportupsertlogfile=Path("pg_upsert.log")iflogfile.exists():logfile.unlink()logging.basicConfig(level=logging.INFO,format="%(message)s",handlers=[logging.FileHandler(logfile),logging.StreamHandler(),],)tables=["customers","purchase_orders",]exclude_cols=["alias",]upsert(host="localhost",database="dbname",user="postgres",# passwd=,  # if not provided, will prompt for passwordtables=tables,stg_schema="staging",base_schema="public",upsert_method="upsert",# "upsert" | "update" | "insert", default: "upsert"commit=False,# optional, default=Falseinteractive=False,# optional, default=Falseexclude_cols=exclude_cols,# optionalexclude_null_check_columns=exclude_cols,# optional)Dockerdockerrun--rm-v$(pwd):/appghcr.io/geocoug/pg_upsert[-h][-q][-d][-lLOGFILE][-eEXCLUDE_COLUMNS][-nNULL_COLUMNS][-c][-i][-mMETHOD]HOSTDATABASEUSERSTAGING_SCHEMABASE_SCHEMATABLE[TABLE...]CreditsThis project was created using inspiration from theExecSQLexample scriptpg_upsert.sql. The goal of this project is to provide a Python implementation of the same functionality without the need for ExecSQL.
Package: pgv
PostgreSQL Schema Versioning Toolpgvis an
open source utility that makes available to support PostgreSQL schemas
in a VCS repository.Overviewpgvhelps you if it is needed to:store SQL files in VCS repository;track changes of your database schemas;make possible to apply changes to various databaseseven if you have just local access to it.InstallationYou can installpgvusingpip:pip install pgvUsageSo, for example, you want to store database schemas in the git
repositoryrepo.gitin folderdb. First of all, you need to
initialize repository:~:    user$ git clone repo.git
~:    user$ cd repo
repo: user$ pgv init -p dbThis command creates simplepgvconfigpgv.yamlin working
directory and folderdb:db/
  schemas/
  scripts/According to the conventionschemassubfolder should contains
folders named after desired schemas in database. Files inside these
directories should be the SQL scripts, that describes corresponding
schema. E.g. you want to create tablefooand functionbarin
schemapublic:schemas/
  public/
    tables/
      foo.sql
    functions/
      bar.sqlScriptssubfolder should contains some staff scripts: data fixes,
migrations and so on. SQL files in this folder can contains prefix that
defines the position on execution flow. E.g. you need to add script that
grants access to all objects in the database. It should be executed
after all other.scripts/
  grants_post.sqlOk, you want to apply committed changes to database. Let’s initialize
it:repo: user$ pgv initdb -d testThan push changes to databasetest:repo: user$ pgv push -c -d testE.g. you’ve made some checks ontestdatabase and you’ve understood
that functionbaris not needed. Let’s skip it:repo: user$ pgv show
c2d658898d4a1369c20285464bd5bb95713173f6
  schemas/public/tables/foo.sql
  schemas/public/functions/bar.sql
  scripts/grants_post.sql
repo: user$ pgv skip -f schemas/public/functions/bar.sql c2d658898d4a1369c20285464bd5bb95713173f6
repo: user$ git add db/.skiplist
repo: user$ git commit
repo: user$ pgv show
cdfdbfb2bdcf8ee2dbf190bbf3a73ffbd77bd9b3 [s]
  .skiplist

c2d658898d4a1369c20285464bd5bb95713173f6
  schemas/public/tables/foo.sql
  scripts/grants_post.sqlAfter fix you want to push changes toproduction, but database
allows only local connections. Let’s make package with changes:repo: user$ pgv collect -o changes-to-prod.tar.gz
repo: user$ scp changes-to-prod.tar.gz prod://tmp
repo: user$ ssh prod
~:    user@prod$ pgv push -i /tmp/changes-to-prod.tar.gz -d prodTestsTo run test use:tox
Package: pgvector-haystack
pgvector-haystackTable of Contentspgvector-haystackInstallationTestingLicenseInstallationpip install pgvector-haystackTestingEnsure that you have a PostgreSQL running with thepgvectorextension. For a quick setup using Docker, run:docker run -d -p 5432:5432 -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=postgres -e POSTGRES_DB=postgres ankane/pgvectorthen run the tests:hatch run testTo run the coverage report:hatch run covLicensepgvector-haystackis distributed under the terms of theApache-2.0license.
Package: pgvecto-rs
Python bindings for pgvecto.rsUsageInstall from PyPI:pipinstallpgvecto_rsSee theusage of SDKOr use it as an extension of postgres clients:SQLAlchemypsycopg3SDKOur SDK is designed to use the pgvecto.rs out-of-box. You can exploit the power of pgvecto.rs to do similarity search or retrieve with filters, without writing any SQL code.Install dependencies:pipinstall"pgvecto_rs[sdk]"A minimal example:frompgvecto_rs.sdkimportPGVectoRs,Record# Create a clientclient=PGVectoRs(db_url="postgresql+psycopg://postgres:mysecretpassword@localhost:5432/postgres",table_name="example",dimension=3,)try:# Add some recordsclient.add_records([Record.from_text("hello 1",[1,2,3]),Record.from_text("hello 2",[1,2,4]),])# Search with default operator (sqrt_euclid).# The results is sorted by distanceforrec,disinclient.search([1,2,5]):print(rec.text)print(dis)finally:# Clean up (i.e. drop the table)client.drop()Output:hello 2
1.0
hello 1
4.0Seeexamples/sdk_example.pyandtests/test_sdk.pyfor more examples.SQLAlchemyInstall dependencies:pipinstall"pgvecto_rs[sqlalchemy]"Then write your code. Seeexamples/sqlalchemy_example.pyandtests/test_sqlalchemy.pyfor example.All the operators include:squared_euclidean_distancenegative_dot_product_distancenegative_cosine_distancepsycopg3Install dependencies:pipinstall"pgvecto_rs[psycopg3]"Then write your code. Seeexamples/psycopg_example.pyandtests/test_psycopg.pyfor example.Known issue:Can not check the length of an vector when inserting it into a table. See:#96.DevelopmentThis package is managed byPDM.Set up things:pdmvenvcreate
pdmuse# select the venv inside the project pathpdmsyncRun lint:pdmrunformat
pdmrunfix
pdmruncheckRun test in current environment:pdmruntestTestToxis used to test the package locally.Run test in all environment:toxrun
Package: pgwait
This command-line tool reads django settings, then tries to connect to
configured postgresql server until connection succeeds. It is useful on
service startup, when you want to launch migrations right after postgres
database gets ready.Installationpip install pgwaitUsageTo wait before migrations:pgwait&&./manage.pymigrateSpecifying settings pathYou can either setDJANGO_SETTINGS_MODULEenvironment variable, or
specify settings module path in the first command-line argument.pgwaitpath.to.settings
Package: pgwasm
pgwasmpgwasm is a Python interface to PostgreSQL proxied over WebSockets for use in
WebAssembly (specifically using Pyodide). It is based on pg8000 and uses
wasmsockets for communication.wasmsockets handles the proxying of WebSocket calls to the Javascript
interface when it detects it is being run in a WebAssembly environment. When
run in a native Python environment, it instead uses the websockets package.
This allows pgwasm to be tested in a native environment. However in both
cases, since all network traffic is proxied over WebSockets, a WebSocket
proxy is also required for the Postgres server; it cannot connect to a
PostgreSQL server directly. The websockify package is convenient for
implementing this proxy to PostgreSQL.
Package: pgwebsocket
Async websocket to PostgreSQL proxy.Installpython3 -m pip install pgwebsocketUsagefrompgwebsocketimportPgWebsocketapp=PgWebsocket("")@app.on_connectasyncdef_on_connect(ctx):awaitctx.execute("LISTEN clients;")@app.on_disconnectasyncdef_on_disconnect(ctx):awaitctx.execute("UNLISTEN clients;")if__name__=='__main__':app.run()
Package: pgwidget
pgwidgetpgwidget is a Python library for easy creation of GUI widgets in pygame environment.InstallationUse the package managerpipto install pgwidget.pipinstallpgwidgetUsageimportpgwidget.pgwidget_coreaspgwbuttons=pgw.PgWidget()button1=pgw.Button([800,100],[80,20],"Submit")buttons.elements.append(button1)pgwidgets=[buttons]pgw.main_program_loop(pgwidgets,None)In examples folder you can get several GUI elements.Examples of UIs possible to create with pgwidgetProject Forloop.aiOlder exampleContributingPull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.LicenseMITCurrently implementedCheckboxRadio buttonButton (image)Button (classical)Table (spreadsheet)
Package: pgworkload-odbc
pgworkload-odbcpgworkload-odbcispgworkload's little brother usingpyodbcandpsqlODBC.SetupMacOSSteps taken fromhttps://www.boriel.com/postgresql-odbc-connection-from-mac-os-x.html.First, installunixODBCbrewinstallunixodbcThen, download latestpsqlODBCsource code fromhttps://www.postgresql.org/ftp/odbc/versions/src/.Unzip, cd to that directory and./configure
make
makeinstallYou will see these files have been built:ll/usr/local/lib/ps*
-rwxr-xr-x1fabioadmin992BJul1809:25/usr/local/lib/psqlodbca.la*
-rwxr-xr-x1fabioadmin557KJul1809:25/usr/local/lib/psqlodbca.so*
-rwxr-xr-x1fabioadmin992BJul1809:25/usr/local/lib/psqlodbcw.la*
-rwxr-xr-x1fabioadmin580KJul1809:25/usr/local/lib/psqlodbcw.so*Create file/usr/local/etc/odbcinst.ini:[PostgreSQL Unicode]Description=PostgreSQL ODBC driver (Unicode version)Driver=psqlodbcw.soDebug=0CommLog=1UsageCount=1Optionally, if you want to use the DSN, create file~/.odbc.ini[fabio]Driver=PostgreSQL UnicodeServerName=localhostPort=5432Database=fabioUsername=fabioPassword=Protocol=13.1.6Debug=1[fabiocrl]Driver=PostgreSQL UnicodeServerName=localhostPort=26257Database=fabioUsername=fabioPassword=Protocol=13.1.6Debug=1Now you can installpyodbcpipinstallpyodbcHere below some sample code, just for reference, as we usepgworkload-odbcto run transactions.importpyodbcAPP_NAME='fab2'# with pyodbc.connect('DSN=fabiocrl') as conn:withpyodbc.connect('Driver={PostgreSQL UNICODE};Server=localhost;Port=26257;Database=fabio;Uid=fabio;Pwd=fabio;sslmode=require',autocommit=True,)asconn:withconn.cursor()ascur:cur.execute(f"SET application_name = '{APP_NAME}'")# cur.execute("select * from fabio;")# while True:#     row = cur.fetchone()#     if not row:#         break#     print(row)forxinrange(500):cur.execute("insert into fabio (id) values (?)",(x,))Running# install pgworkload_odbcpipinstallpgworkload_odbc# run itpgworkload-odbcrun-wworkloads/bank.py--url'Driver={PostgreSQL UNICODE};Server=localhost;Port=26257;Database=bank;Uid=fabio;Pwd=fabio;sslmode=require'-c1
Package: pgwrapper
pgwrapperA simple, fast way to access postgresql in python.DescriptionIt is a postgresql python connection pool at lower layer.It is a mongo-like query formula system upper layer.It is a new version to access postgresql in python3.Installpip install pgwrapperUsage>>> import pgwrapper
>>> pg = pgwrapper.PGWrapper(
        dbname='postgres',
        user='postgres',
        password='',
        host='127.0.0.1',
        port=5432)
>>> r = pg.select('company', 'id, name', 'address is not null', 'limit 2')
>>> print(r)

[(12, 'sun'), (34, 'moon')]select>>> select('hospital', 'id, city', control='limit 1')
    select id, city from hospital limit 1;


    >>> select('hospital', 'id', 'address is null')
    select id from hospital where address is null;update>>> update('dept', {'name': 'design', 'quantity': 3}, {'id': 'we4d'})
    update dept set name='design', quantity=3 where id='we4d';

    >>> update('dept', {'name': 'design', 'quantity': 3}, 'introduction is null')
    update dept set name='design', quantity=3 where introduction is null;

    >>> update('physician', {'$inc': {'status': -10}, 'present': 0}, {'id': 'someid'})
    update physician set status=status+-10, present=0 where id='someid';insert>>> insert('hospital', {'id': '12de3wrv', 'province': 'shanghai'})
    insert into hospital (id, province) values ('12de3wrv', 'shanghai');insert use list way:>>> insert_list('hospital', ['id', 'province'], ['12de3wrv', 'shanghai'])
    insert into hospital (id, province) values ('12de3wrv', 'shanghai');insert if the record not in the table:>>> insert_inexistence('hospital', {'id': '12de3wrv', 'province': 'shanghai'}, {'id': '12de3wrv'})
    insert into hospital (id, province) select '12de3wrv', 'shanghai' where not exists (select 1 from hospital where id='12de3wrv' limit 1);delete>>> delete('hospital', {'id': '12de3wrv'})
    delete from hospital where id='12de3wrv';joincomman join>>> joint('user', 'name, id_number', 'medical_card', 'number', 'id', 'user_id', 'inner_join')
    select u.name, u.id_number, v.number from user as u inner join medical_card as v on u.id=v.user_id;left join>>> select_join('hospital', 'id', 'department', 'hospid')
    select hospital.id from hospital left join department on hospital.id=department.hospid where department.hospid is null;IssueError: pg_config executable not found.If you meet this following error when installing psycopg2, you may need to install extra library.In Ubuntu:sudo apt install libpq-devIn macOs:brew install postgresql
Package: pgx-minatar
MinAtar extension for Pgxhttps://www.gnu.org/licenses/gpl-faq.en.html#GPLPluginsWhen is a program and its plug-ins considered a single combined program? (#GPLPlugins)
It depends on how the main program invokes its plug-ins. If the main program uses fork and exec to invoke plug-ins, and they establish intimate communication by sharing complex data structures, or shipping complex data structures back and forth, that can make them one single combined program.A main program that uses simple fork and exec to invoke plug-ins and does not establish intimate communication between them results in the plug-ins being a separate program.Note thatPgxjust invokepgx-minatarenvironments throughpgx.make(e.g.,env = pgx.make("minatar-asterix")).
All MinAtar environment dynamics are implemented in this MinAtar extension repository.
Package: pgxnclient
ThePGXN Clientis a command
line tool designed to interact with thePostgreSQL Extension Networkallowing searching, compiling, installing, and removing
extensions in PostgreSQL databases.For example, to install thesemverextension, the client can be invoked as:$ pgxn install semverwhich would download and compile the extension for one of the PostgreSQL
servers hosted on the machine and:$ pgxn load -d somedb semverwhich would load the extension in one of the databases of the server.The client interacts with the PGXN web service and aMakefileprovided by
the extension. The best results are achieved with makefiles using the
PostgreSQLExtension Building Infrastructure; however the client tries to
degrade gracefully in presence of any package hosted on PGXN.Documentation:https://pgxn.github.io/pgxnclient/Source repository:https://github.com/pgxn/pgxnclientDownloads:https://pypi.python.org/pypi/pgxnclient/Discussion group:https://groups.google.com/group/pgxn-users/Please refer to the files in thedocsdirectory oronlinefor
instructions about the program installation and usage.DevelopmentYou can create a local development environment with:virtualenv .venv
source .venv/bin/activate
pip install -e .[dev]and runpytestto run the test suite.
Package: pgxsq
pgxsqpgxsq simplifies writingPostgres extensions(especially those relying onprocedural languages) by managing changes withSqitch.Tracking changes in Postgres extensions is not easy.  Updating procedures or
views requires copying the defintion and make the necessary changes.  This has
a major drawback: the changes made are not obvious without resorting todiff.
Wouldn't it be great to track changes in version control and use, for example,
justgit diffto see what changes were made?pgxsq allows that by tracking changes withSqitchand generating extension
scripts from those changes.  Changes are made byreworkingthe scripts that define the extension objects.  Sqitch caries out the grunt
work of tracking the original script version so that the script can be modified
and tracked in version control.  pgxsq builds the extension update paths from
the Sqitchtagsthat are required for reworking.ExampleThis repository contains anexamplethat shows the steps from
creating the Sqitch project to making changes to installing the extension.InstallationInstall withpip:pip install pgxsqInstall from source:make installYou also need toinstallSqitch to create projects and use
pgxsq.Developmentmake
Package: pgzero
A zero-boilerplate games programming framework for Python 3, based on Pygame.Some examplesPygame Zero consists of a runnerpgzrunthat will run a Pygame Zero script
with a full game loop and a range of useful builtins.Here’s some of the neat stuff you can do. Note that each of these is a
self-contained script. There’s no need for any imports or anything else in the
file.Draw graphics (assuming there’s  a file likeimages/dog.pngorimages/dog.jpg):def draw():
    screen.clear()
    screen.blit('dog', (10, 50))Play the soundsounds/eep.wavwhen you click the mouse:def on_mouse_down():
    sounds.eep.play()Draw an “actor” object (with the spriteimages/alien.png) that moves across
the screen:alien = Actor('alien')
alien.pos = 10, 10

def draw():
    screen.clear()
    alien.draw()

def update():
    alien.x += 1
    if alien.left > WIDTH:
        alien.right = 0InstallationSeeinstallation instructions.DocumentationThe full documentation is athttp://pygame-zero.readthedocs.org/.Read the tutorial athttp://pygame-zero.readthedocs.org/en/latest/introduction.htmlfor a taste of the other things that Pygame Zero can do.ContributingThe project is hosted on Github:https://github.com/lordmauve/pgzeroIf you want to help out with the development of Pygame Zero, you can find some
instructions on setting up a development version in the docs:http://pygame-zero.readthedocs.org/en/latest/contributing.html
Package: pgzero-api-stub
This is a stub for pgzero.It helps ides (such as vscode, pychram, and so on) provide better code hints and syntax checks.它可以帮助IDE（如vscode、pychram等等）提供更好的代码提示和语法检查。You only should type some like this:您可以这样使用它：frompgzero_api_stubimport*importpgzrunNote:pgzero_api_stubmust be in front ofpgzrun.注意：pgzero_api_stub必须在pgzrun的前面。
Package: pgzero-yt
A zero-boilerplate games programming framework for Python 3, based on Pygame.Some examplesPygame Zero consists of a runnerpgzrunthat will run a Pygame Zero script
with a full game loop and a range of useful builtins.Here’s some of the neat stuff you can do. Note that each of these is a
self-contained script. There’s no need for any imports or anything else in the
file.Draw graphics (assuming there’s  a file likeimages/dog.pngorimages/dog.jpg):def draw():
    screen.clear()
    screen.blit('dog', (10, 50))Play the soundsounds/eep.wavwhen you click the mouse:def on_mouse_down():
    sounds.eep.play()Draw an “actor” object (with the spriteimages/alien.png) that moves across
the screen:alien = Actor('alien')
alien.pos = 10, 10

def draw():
    screen.clear()
    alien.draw()

def update():
    alien.x += 1
    if alien.left > WIDTH:
        alien.right = 0InstallationSeeinstallation instructions.DocumentationThe full documentation is athttp://pygame-zero.readthedocs.org/.Read the tutorial athttp://pygame-zero.readthedocs.org/en/latest/introduction.htmlfor a taste of the other things that Pygame Zero can do.ContributingThe project is hosted on Github:https://github.com/lordmauve/pgzeroIf you want to help out with the development of Pygame Zero, you can find some
instructions on setting up a development version in the docs:http://pygame-zero.readthedocs.org/en/latest/contributing.html
Package: pgzip
pgzippgzipis a multi-threadedgzipimplementation forpythonthat increases the compression and decompression performance.Compression and decompression performance gains are made by parallelizing the usage of block indexing within agzipfile. Block indexing utilizes gzip'sFEXTRAfeature which records the index of compressed members.FEXTRAis defined in the officialgzipspecification starting at version 4.3. BecauseFEXTRAis part of thegzipspecification,pgzipis compatible with regulargzipfiles.pgzipis~25Xfaster for compression and~7Xfaster for decompression when benchmarked on a 24 core machine. Performance is limited only by I/O and thepythoninterpreter.Theoretically, the compression and decompression speed should be linear with the number of cores available. However, I/O and a language's general performance limits the compression and decompression speed in practice.Usage and ExamplesCLI❯ python -m pgzip -h
usage: __main__.py [-h] [-o OUTPUT] [-f FILENAME] [-d] [-l {0-9}] [-t THREADS] input

positional arguments:
  input                 Input file or '-' for stdin

options:
  -h, --help            show this help message and exit
  -o OUTPUT, --output OUTPUT
                        Output file or '-' for stdout (Default: Input file with 'gz' extension or stdout)
  -f FILENAME, --filename FILENAME
                        Name for the original file when compressing
  -d, --decompress      Decompress instead of compress
  -l {0-9}, --compression-level {0-9}
                        Compression level; 0 = no compression (Default: 9)
  -t THREADS, --threads THREADS
                        Number of threads to use (Default: Determine automatically)ProgramaticallyUsingpgzipis the same as using the built-ingzipmodule.Compressing data and writing it to a file:importpgzips="a big string..."# An explanation of parameters:# `thread=8` - Use 8 threads to compress. `None` or `0` uses all cores (default)# `blocksize=2*10**8` - Use a compression block size of 200MBwithpgzip.open("test.txt.gz","wt",thread=8,blocksize=2*10**8)asfw:fw.write(s)Decompressing data from a file:importpgzips="a big string..."withpgzip.open("test.txt.gz","rt",thread=8)asfr:assertfr.read(len(s))==sPerformanceCompression PerformanceDecompression PerformanceDecompression was benchmarked using an 8.0GBFASTQtext file with 48 threads across 24 cores on a machine with Xeon(R) E5-2650 v4 @ 2.20GHz CPUs.The compressed file used in this benchmark was created with a blocksize of 200MB.Warningpgziponly replaces the following methods ofgzip'sGzipFileclass:open()compress()decompress()Other class methods and functionality have not been well tested.Contributions or improvements is appreciated for methods such as:seek()tell()HistoryCreated initially by Vincent Li (@vinlyx), this project is a fork ofhttps://github.com/vinlyx/mgzip. We had several bug fixes to implement, but we could not contact them. Thepgzipteam would like to thank Vincent Li (@vinlyx) for their hard work. We hope that they will contact us when they discover this project.