Home

Đorđe Cvijanović

Project Admins:

pgApex

Web Rapid Application Development tool for PostgreSQL.

How it works

CherryPy is HTTP server (listener) which keep information about session. CherryPy forwards requests including session variables from client to PostgreSQL database. In database, stored procedure using session information, variables, etc. and database tables "draws" application pages and return html (java script) code to CherryPy. CherryPy than returns html page to client. And back to start...

What you need?

PostgreSQL, Python, CherryPy (http://www.cherrypy.org/), psycopg2 (http://initd.org/psycopg/download/ or http://www.stickpeople.com/projects/python/win-psycopg/ for windows), , ..., plpgsql as programming language, hstore data type, pldbgapi for debuging, adminpack for I don't know why.

I use PostgreSQL v9.1, Python 3.2, CherryPy 3.2 and psycopg2-2.4.2.

It can work with PostgreSQL 8.x and 9.x and Python 2.6, CherrPy 2.3. Only diference is that you have to change print(something) to print something in pgApex.py.

  • Install Python and PostgreSQL.
  • Download and install CherryPy and psycopg2-2.4.2.
  • Create database and login role with password.

CREATE DATABASE <username>
WITH OWNER = <username>
ENCODING = 'UTF8'
TABLESPACE = pg_default
LC_COLLATE = 'Serbian (Latin)_Serbia and Montenegro (Former).1250'
LC_CTYPE = 'Serbian (Latin)_Serbia and Montenegro (Former).1250'
CONNECTION LIMIT = -1;

Be aware that PostgreSQL make difference between downcase and upcase letters. So pgApex is acctually pgapex and "pgApex" is pgApex. If you want to use upcase letters than use ".

CREATE ROLE <username> LOGIN PASSWORD '<password>'
SUPERUSER INHERIT CREATEDB CREATEROLE REPLICATION;

  • Unzip pgApex zip in some directory. Open console in that directory
  • Import file create_pgApex_schema.sql into database (it will create schema and hstore and some other extensions) - type password

psql.exe -U <username> < create_pgApex_schema.sql

  • Import file insert_data_into_pgApex_schema.sql into database (it will populate tables with values) - type password

psql.exe -U <username> < insert_data_into_pgApex_schema.sql

  • Open pgApex.py in editor and change lines

conn = psycopg2.connect("dbname=<database name> user=<username> password=<password>")

  • Start pgApex.py typing

python pgapex.py

You will get Login page. Put a as username and a as password (a/a) and you will login to page 1.

Still, I am not sure ...

  1. Is it better to wrote all code in python (not to use stored procedure)? This way same code can be used for many databases.
  2. Which js framework to use? jQuery is first choice (I use hive-dark theme).

Comment

This is my first OSS project. I have a lot other job to do, so time is short.