Skip to content

Commit

Permalink
updated version to enable new release
Browse files Browse the repository at this point in the history
  • Loading branch information
orm011 committed Apr 23, 2024
1 parent 301d517 commit 8da8c00
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 152 deletions.
182 changes: 31 additions & 151 deletions pgserver-example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,9 @@
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Requirement already satisfied: pgserver in /Users/orm/mambaforge/envs/pixeltable_39/lib/python3.9/site-packages (0.1.1)\n",
"Requirement already satisfied: sqlalchemy in /Users/orm/mambaforge/envs/pixeltable_39/lib/python3.9/site-packages (2.0.25)\n",
"Requirement already satisfied: psycopg2-binary in /Users/orm/mambaforge/envs/pixeltable_39/lib/python3.9/site-packages (2.9.9)\n",
"Requirement already satisfied: sqlalchemy_utils in /Users/orm/mambaforge/envs/pixeltable_39/lib/python3.9/site-packages (0.41.1)\n",
"Requirement already satisfied: fasteners>=0.19 in /Users/orm/mambaforge/envs/pixeltable_39/lib/python3.9/site-packages (from pgserver) (0.19)\n",
"Requirement already satisfied: platformdirs>=4.0.0 in /Users/orm/mambaforge/envs/pixeltable_39/lib/python3.9/site-packages (from pgserver) (4.1.0)\n",
"Requirement already satisfied: psutil>=5.9.0 in /Users/orm/mambaforge/envs/pixeltable_39/lib/python3.9/site-packages (from pgserver) (5.9.7)\n",
"Requirement already satisfied: typing-extensions>=4.6.0 in /Users/orm/mambaforge/envs/pixeltable_39/lib/python3.9/site-packages (from sqlalchemy) (4.9.0)\n"
]
}
],
"outputs": [],
"source": [
"!pip install pgserver sqlalchemy psycopg2-binary sqlalchemy_utils"
]
Expand All @@ -31,177 +16,72 @@
"outputs": [],
"source": [
"import pgserver\n",
"srv = pgserver.get_server('./my_pgdata')"
"srv = pgserver.get_server('./mypgdata')"
]
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 3,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Available help:\n",
" ABORT CREATE USER MAPPING\n",
" ALTER AGGREGATE CREATE VIEW\n",
" ALTER COLLATION DEALLOCATE\n",
" ALTER CONVERSION DECLARE\n",
" ALTER DATABASE DELETE\n",
" ALTER DEFAULT PRIVILEGES DISCARD\n",
" ALTER DOMAIN DO\n",
" ALTER EVENT TRIGGER DROP ACCESS METHOD\n",
" ALTER EXTENSION DROP AGGREGATE\n",
" ALTER FOREIGN DATA WRAPPER DROP CAST\n",
" ALTER FOREIGN TABLE DROP COLLATION\n",
" ALTER FUNCTION DROP CONVERSION\n",
" ALTER GROUP DROP DATABASE\n",
" ALTER INDEX DROP DOMAIN\n",
" ALTER LANGUAGE DROP EVENT TRIGGER\n",
" ALTER LARGE OBJECT DROP EXTENSION\n",
" ALTER MATERIALIZED VIEW DROP FOREIGN DATA WRAPPER\n",
" ALTER OPERATOR DROP FOREIGN TABLE\n",
" ALTER OPERATOR CLASS DROP FUNCTION\n",
" ALTER OPERATOR FAMILY DROP GROUP\n",
" ALTER POLICY DROP INDEX\n",
" ALTER PROCEDURE DROP LANGUAGE\n",
" ALTER PUBLICATION DROP MATERIALIZED VIEW\n",
" ALTER ROLE DROP OPERATOR\n",
" ALTER ROUTINE DROP OPERATOR CLASS\n",
" ALTER RULE DROP OPERATOR FAMILY\n",
" ALTER SCHEMA DROP OWNED\n",
" ALTER SEQUENCE DROP POLICY\n",
" ALTER SERVER DROP PROCEDURE\n",
" ALTER STATISTICS DROP PUBLICATION\n",
" ALTER SUBSCRIPTION DROP ROLE\n",
" ALTER SYSTEM DROP ROUTINE\n",
" ALTER TABLE DROP RULE\n",
" ALTER TABLESPACE DROP SCHEMA\n",
" ALTER TEXT SEARCH CONFIGURATION DROP SEQUENCE\n",
" ALTER TEXT SEARCH DICTIONARY DROP SERVER\n",
" ALTER TEXT SEARCH PARSER DROP STATISTICS\n",
" ALTER TEXT SEARCH TEMPLATE DROP SUBSCRIPTION\n",
" ALTER TRIGGER DROP TABLE\n",
" ALTER TYPE DROP TABLESPACE\n",
" ALTER USER DROP TEXT SEARCH CONFIGURATION\n",
" ALTER USER MAPPING DROP TEXT SEARCH DICTIONARY\n",
" ALTER VIEW DROP TEXT SEARCH PARSER\n",
" ANALYZE DROP TEXT SEARCH TEMPLATE\n",
" BEGIN DROP TRANSFORM\n",
" CALL DROP TRIGGER\n",
" CHECKPOINT DROP TYPE\n",
" CLOSE DROP USER\n",
" CLUSTER DROP USER MAPPING\n",
" COMMENT DROP VIEW\n",
" COMMIT END\n",
" COMMIT PREPARED EXECUTE\n",
" COPY EXPLAIN\n",
" CREATE ACCESS METHOD FETCH\n",
" CREATE AGGREGATE GRANT\n",
" CREATE CAST IMPORT FOREIGN SCHEMA\n",
" CREATE COLLATION INSERT\n",
" CREATE CONVERSION LISTEN\n",
" CREATE DATABASE LOAD\n",
" CREATE DOMAIN LOCK\n",
" CREATE EVENT TRIGGER MERGE\n",
" CREATE EXTENSION MOVE\n",
" CREATE FOREIGN DATA WRAPPER NOTIFY\n",
" CREATE FOREIGN TABLE PREPARE\n",
" CREATE FUNCTION PREPARE TRANSACTION\n",
" CREATE GROUP REASSIGN OWNED\n",
" CREATE INDEX REFRESH MATERIALIZED VIEW\n",
" CREATE LANGUAGE REINDEX\n",
" CREATE MATERIALIZED VIEW RELEASE SAVEPOINT\n",
" CREATE OPERATOR RESET\n",
" CREATE OPERATOR CLASS REVOKE\n",
" CREATE OPERATOR FAMILY ROLLBACK\n",
" CREATE POLICY ROLLBACK PREPARED\n",
" CREATE PROCEDURE ROLLBACK TO SAVEPOINT\n",
" CREATE PUBLICATION SAVEPOINT\n",
" CREATE ROLE SECURITY LABEL\n",
" CREATE RULE SELECT\n",
" CREATE SCHEMA SELECT INTO\n",
" CREATE SEQUENCE SET\n",
" CREATE SERVER SET CONSTRAINTS\n",
" CREATE STATISTICS SET ROLE\n",
" CREATE SUBSCRIPTION SET SESSION AUTHORIZATION\n",
" CREATE TABLE SET TRANSACTION\n",
" CREATE TABLE AS SHOW\n",
" CREATE TABLESPACE START TRANSACTION\n",
" CREATE TEXT SEARCH CONFIGURATION TABLE\n",
" CREATE TEXT SEARCH DICTIONARY TRUNCATE\n",
" CREATE TEXT SEARCH PARSER UNLISTEN\n",
" CREATE TEXT SEARCH TEMPLATE UPDATE\n",
" CREATE TRANSFORM VACUUM\n",
" CREATE TRIGGER VALUES\n",
" CREATE TYPE WITH\n",
" CREATE USER \n",
" res \n",
"-----\n",
" 2\n",
"(1 row)\n",
"\n",
"\n"
]
}
],
"source": [
"print(srv.psql('\\h'))"
"print(srv.psql('SELECT 1+1 as res;'))"
]
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
"from sqlalchemy_utils import create_database, database_exists\n",
"from sqlalchemy import create_engine\n",
"import sqlalchemy as sql"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'postgresql://postgres:@/mydb?host=/Users/orm/repos/pgserver/my_pgdata'"
"'postgresql://postgres:@/mydb?host=/Users/orm/repos/pgserver/mypgdata'"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
"output_type": "display_data"
}
],
"source": [
"dburi = srv.get_uri(database='mydb')\n",
"dburi"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
"from sqlalchemy_utils import create_database\n",
"create_database(dburi)"
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {},
"outputs": [],
"source": [
"from sqlalchemy import create_engine\n",
"import sqlalchemy as sql"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [],
"source": [
"display(dburi)\n",
"if not database_exists(dburi):\n",
" create_database(dburi)\n",
"engine = create_engine(dburi)"
]
},
{
"cell_type": "code",
"execution_count": 23,
"execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
"table_name = 'example_table'\n",
"table_name = 'mytable'\n",
"with engine.connect() as conn:\n",
" conn.execute(sql.text(f\"create table {table_name} (id int);\"))\n",
" conn.execute(sql.text(f\"insert into {table_name} values (1);\"))\n",
Expand All @@ -211,7 +91,7 @@
},
{
"cell_type": "code",
"execution_count": 17,
"execution_count": 7,
"metadata": {},
"outputs": [
{
Expand All @@ -220,7 +100,7 @@
"(1,)"
]
},
"execution_count": 17,
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "pgserver" # Required
version = "0.1.1" # Required
version = "0.1.2" # Required
description = "Self-contained postgres server for your python applications" # Required
readme = "README.md" # Optional
requires-python = ">=3.9"
Expand Down

0 comments on commit 8da8c00

Please sign in to comment.