summaryrefslogtreecommitdiffstats
path: root/examples/SQL
diff options
context:
space:
mode:
Diffstat (limited to 'examples/SQL')
-rw-r--r--examples/SQL/README76
-rw-r--r--examples/SQL/connect.ui238
-rw-r--r--examples/SQL/connect.ui.h21
-rwxr-xr-xexamples/SQL/dbconnect.py82
-rw-r--r--examples/SQL/dbpar.py22
-rw-r--r--examples/SQL/form1.ui77
-rw-r--r--examples/SQL/form2.ui327
-rw-r--r--examples/SQL/frmconnect.py120
-rw-r--r--examples/SQL/frmconnect.ui245
-rwxr-xr-xexamples/SQL/runform1.py21
-rwxr-xr-xexamples/SQL/runform2.py21
-rwxr-xr-xexamples/SQL/runsqlex.py151
-rwxr-xr-xexamples/SQL/sqlcustom1.py94
-rw-r--r--examples/SQL/sqlex.ui303
-rw-r--r--examples/SQL/sqlex.ui.h35
-rwxr-xr-xexamples/SQL/sqlsubclass5.py151
-rwxr-xr-xexamples/SQL/sqltable4.py118
-rw-r--r--examples/SQL/testdb_mysql.sql57
-rw-r--r--examples/SQL/testdb_pg.sql232
19 files changed, 2391 insertions, 0 deletions
diff --git a/examples/SQL/README b/examples/SQL/README
new file mode 100644
index 0000000..862e608
--- /dev/null
+++ b/examples/SQL/README
@@ -0,0 +1,76 @@
+This directory contains some translated sql examples from TQt 3.x.
+
+runform1.py, form1.ui:
+
+ A simple designer generated TQDataTable. Run "pyuic form1.ui -o form1.py".
+
+runform2.py, form2.ui:
+
+ A simple designer generated TQDataBrowser. Run "pyuic form2.ui -o form2.py".
+
+sqlcustom1.py:
+
+ TQSqlForm based form with a simple custom editor forcing all input to
+ be uppercase
+
+sqltable4.py:
+
+ Custom TQDataTable with reimplemented paintField method, combined with
+ a TQComboBox based custom field editor (StatusPicker), gathering its
+ items from a different table (status) and a calculated column (monsalary).
+ Note, that TQSqlEditorFactory based field editors are somewhat restricted,
+ because TQt's TQ_PROPERTY feature isn't supported, yet. I've circumvented
+ this limitation by choosing the status table ids corresponding to the
+ index in the TQComboBox.
+
+sqlsubclass5.py:
+
+ Similar to the former, and even more deviated from its qt ancestor,
+ because the sense escaped me. This could be related to the different
+ database layout needed for MySQL (Trolltech used PostgreSQL sequences,
+ while we're using the simpler, but less powerful auto_increment here).
+ If you enter and invalid date (e.g. day: 0) in the Paid column, it is
+ shown as "not yet", but produces some qt warnings.
+
+runsqlex.py, sqlex.ui, sqlex.ui.h, connect.ui, connect.ui.h:
+
+ This one is a most advanced example, showing the use of a TQSqlCursor
+ driven by TQSqlQuery and iterating through database tables and fields.
+ Definitely worth a look.
+
+Unfortunately you will have to make sure that these prerequisites are met
+before trying the examples:
+
+ - Install MySQL or PostgreSQL and any development packages
+
+ - Create a database user with sufficient rights
+
+ - Create the testdb database
+ - For MySQL, run: mysql -u user -p password < testdb_mysql.sql
+ - For PostgreSQL, run: psql -U user template1 -f testdb_pg.sql
+
+ - Build TQt with the mysql and/or psql modules activated.
+
+Now you should be ready for the fun part. You can run dbconnect.py from
+a command line and try to connect to the database. If all went well,
+'ok' should be printed after pressing OK. If you don't want to enter all
+your data over and over again, create a file named local_dbpar.py here,
+with the following keys (with your own data, of course):
+
+DB_HOSTNAMES = ["localhost"]
+DB_DATABASES = ["testdb"]
+DB_USERNAME = "name"
+DB_PASSWORD = "pass"
+
+The dbconnect.py script is generated from dbconnect.ui, which was created
+with qt's designer. You can find it also in Boudewijn Rempt's book
+"GUI Programming with Python, using the TQt Toolkit". Although you won't find
+the SQL widgets discussed there, for the simple reason of the book being
+written before they appeared, it is a valuable source for anybody new in
+this area.
+
+Please direct any comments, patches and questions to <pytde@mats.gmd.de>.
+
+Good luck
+
+Hans-Peter Jansen <hpj@urpla.net>
diff --git a/examples/SQL/connect.ui b/examples/SQL/connect.ui
new file mode 100644
index 0000000..d33a783
--- /dev/null
+++ b/examples/SQL/connect.ui
@@ -0,0 +1,238 @@
+<!DOCTYPE UI><UI version="3.0" stdsetdef="1">
+<class>ConnectDialog</class>
+<widget class="TQDialog">
+ <property name="name">
+ <cstring>ConnectDialog</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>303</width>
+ <height>251</height>
+ </rect>
+ </property>
+ <property name="caption">
+ <string>Connect...</string>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>11</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <widget class="TQGroupBox">
+ <property name="name">
+ <cstring>GroupBox3</cstring>
+ </property>
+ <property name="title">
+ <string>Connection settings</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>11</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <widget class="TQLineEdit" row="1" column="1">
+ <property name="name">
+ <cstring>editDatabase</cstring>
+ </property>
+ </widget>
+ <widget class="TQLabel" row="1" column="0">
+ <property name="name">
+ <cstring>TextLabel3</cstring>
+ </property>
+ <property name="text">
+ <string>Database Name:</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>comboDatabase</cstring>
+ </property>
+ </widget>
+ <widget class="TQLineEdit" row="3" column="1">
+ <property name="name">
+ <cstring>editPassword</cstring>
+ </property>
+ <property name="echoMode">
+ <enum>Password</enum>
+ </property>
+ </widget>
+ <widget class="TQLabel" row="2" column="0">
+ <property name="name">
+ <cstring>TextLabel4</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Username:</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>editUsername</cstring>
+ </property>
+ </widget>
+ <widget class="TQLabel" row="3" column="0">
+ <property name="name">
+ <cstring>TextLabel4_2</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Password:</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>editPassword</cstring>
+ </property>
+ </widget>
+ <widget class="TQComboBox" row="0" column="1">
+ <property name="name">
+ <cstring>comboDriver</cstring>
+ </property>
+ </widget>
+ <widget class="TQLineEdit" row="2" column="1">
+ <property name="name">
+ <cstring>editUsername</cstring>
+ </property>
+ </widget>
+ <widget class="TQLineEdit" row="4" column="1">
+ <property name="name">
+ <cstring>editHostname</cstring>
+ </property>
+ </widget>
+ <widget class="TQLabel" row="4" column="0">
+ <property name="name">
+ <cstring>TextLabel5</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Hostname:</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>editHostname</cstring>
+ </property>
+ </widget>
+ <widget class="TQLabel" row="5" column="0">
+ <property name="name">
+ <cstring>TextLabel5_2</cstring>
+ </property>
+ <property name="text">
+ <string>P&amp;ort:</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>portSpinBox</cstring>
+ </property>
+ </widget>
+ <widget class="TQSpinBox" row="5" column="1">
+ <property name="name">
+ <cstring>portSpinBox</cstring>
+ </property>
+ <property name="specialValueText">
+ <string>Default</string>
+ </property>
+ <property name="maxValue">
+ <number>65535</number>
+ </property>
+ <property name="minValue">
+ <number>-1</number>
+ </property>
+ <property name="value">
+ <number>-1</number>
+ </property>
+ </widget>
+ <widget class="TQLabel" row="0" column="0">
+ <property name="name">
+ <cstring>TextLabel2</cstring>
+ </property>
+ <property name="text">
+ <string>D&amp;river</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>comboDriver</cstring>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="TQLayoutWidget">
+ <property name="name">
+ <cstring>Layout25</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <spacer>
+ <property name="name">
+ <cstring>Spacer1</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ </spacer>
+ <widget class="TQPushButton">
+ <property name="name">
+ <cstring>PushButton1</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;OK</string>
+ </property>
+ <property name="default">
+ <bool>true</bool>
+ </property>
+ </widget>
+ <widget class="TQPushButton">
+ <property name="name">
+ <cstring>PushButton2</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Cancel</string>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ </vbox>
+</widget>
+<connections>
+ <connection>
+ <sender>PushButton1</sender>
+ <signal>clicked()</signal>
+ <receiver>ConnectDialog</receiver>
+ <slot>accept()</slot>
+ </connection>
+ <connection>
+ <sender>PushButton2</sender>
+ <signal>clicked()</signal>
+ <receiver>ConnectDialog</receiver>
+ <slot>reject()</slot>
+ </connection>
+</connections>
+<tabstops>
+ <tabstop>comboDriver</tabstop>
+ <tabstop>editDatabase</tabstop>
+ <tabstop>editUsername</tabstop>
+ <tabstop>editPassword</tabstop>
+ <tabstop>editHostname</tabstop>
+ <tabstop>portSpinBox</tabstop>
+ <tabstop>PushButton1</tabstop>
+ <tabstop>PushButton2</tabstop>
+</tabstops>
+<includes>
+ <include location="local" impldecl="in implementation">connect.ui.h</include>
+</includes>
+<slots>
+ <slot>init()</slot>
+ <slot>destroy()</slot>
+</slots>
+<layoutdefaults spacing="6" margin="11"/>
+</UI>
diff --git a/examples/SQL/connect.ui.h b/examples/SQL/connect.ui.h
new file mode 100644
index 0000000..ceff8dc
--- /dev/null
+++ b/examples/SQL/connect.ui.h
@@ -0,0 +1,21 @@
+/****************************************************************************
+** ui.h extension file, included from the uic-generated form implementation.
+**
+** If you wish to add, delete or rename slots use TQt Designer which will
+** update this file, preserving your code. Create an init() slot in place of
+** a constructor, and a destroy() slot in place of a destructor.
+*****************************************************************************/
+
+
+void ConnectDialog::init()
+{
+from python_tqt.qtsql import TQSqlDatabase
+#qDebug("ConnectDialog init")
+self.comboDriver.clear()
+self.comboDriver.insertStringList(TQSqlDatabase.drivers())
+}
+
+void ConnectDialog::destroy()
+{
+
+}
diff --git a/examples/SQL/dbconnect.py b/examples/SQL/dbconnect.py
new file mode 100755
index 0000000..d1c1baf
--- /dev/null
+++ b/examples/SQL/dbconnect.py
@@ -0,0 +1,82 @@
+#!/usr/bin/env python
+
+import sys
+from python_tqt.qt import *
+from python_tqt.qtsql import *
+
+from frmconnect import frmConnect
+from dbpar import *
+
+TRUE = 1
+FALSE = 0
+
+def createConnection():
+ driver = DB_DRIVER
+ # all qt examples use TQSqlDatabase::addDatabase, but
+ # this never returns NULL in my experience
+ drivers = list(map(str, TQSqlDatabase.drivers()))
+ if driver in drivers:
+ dlg = dbConnect(driver)
+ #TODO: make connection parameters accessible
+ return dlg.exec_loop()
+ else:
+ TQMessageBox.warning(None, "Database Error",
+ "<%s> database driver not found!\n\n"
+ "Please make sure, that this database adaptor\n"
+ "is available in your TQt installation.\n" %
+ (driver), TQMessageBox.Abort | TQMessageBox.Escape)
+ return FALSE
+
+class dbConnect(frmConnect):
+ def __init__(self, driver, parent = None):
+ frmConnect.__init__(self, parent)
+ self.hostnames = DB_HOSTNAMES
+ self.hostname = DB_HOSTNAMES[0]
+ self.databases = DB_DATABASES
+ self.database = DB_DATABASES[0]
+ self.username = DB_USERNAME
+ self.password = DB_PASSWORD
+ self.dbdriver = driver
+
+ self.txtName.setText(self.username)
+ self.txtPasswd.setText(self.password)
+ list(map(self.cmbServer.insertItem, self.hostnames))
+ list(map(self.cmbDatabase.insertItem, self.databases))
+ self.connect(self.buttonHelp, SIGNAL("clicked()"),
+ self.buttonHelp_clicked)
+
+ def accept(self):
+ self.hostname = self.cmbServer.currentText()
+ self.database = self.cmbDatabase.currentText()
+ self.username = self.txtName.text()
+ self.password = self.txtPasswd.text()
+ db = TQSqlDatabase.addDatabase(self.dbdriver)
+ if db:
+ db.setHostName(self.hostname)
+ db.setDatabaseName(self.database)
+ db.setUserName(self.username)
+ db.setPassword(self.password)
+ if db.open():
+ frmConnect.accept(self)
+ else:
+ TQMessageBox.warning(self, "Database Error",
+ "Cannot open %s database on %s!\n\n%s\n%s\n" %
+ (self.database, self.hostname,
+ db.lastError().driverText(),
+ db.lastError().databaseText()), " Ooops ")
+
+
+ def buttonHelp_clicked(self):
+ TQMessageBox.information(self, "About Connecting",
+ "Here you specify userid, password, host and database\n"
+ "for the PyTQt sql examples. If you encounter any problems,\n"
+ "please read the README file in this folder before posting.\n\n"
+ "Thanks,\nHans-Peter Jansen <hpj@urpla.net>\n")
+
+
+if __name__ == "__main__":
+ app = TQApplication(sys.argv)
+ if createConnection():
+ print("ok")
+ else:
+ print("cancel")
diff --git a/examples/SQL/dbpar.py b/examples/SQL/dbpar.py
new file mode 100644
index 0000000..19e6d9b
--- /dev/null
+++ b/examples/SQL/dbpar.py
@@ -0,0 +1,22 @@
+# sql examples default database parameter
+
+# you can create a local_dbpar.py module with definitons
+# of your own parameters to overrule these defaults
+
+#DB_DRIVER = "TQPSQL7"
+DB_DRIVER = "TQMYSQL3"
+# list of servers
+DB_HOSTNAMES = ["localhost"]
+# list of databases
+DB_DATABASES = ["testdb"]
+# database user id
+DB_USERNAME = ""
+# database password
+DB_PASSWORD = ""
+
+# remove this in your local_dbpar.py
+try:
+ from local_dbpar import *
+except:
+ pass
+
diff --git a/examples/SQL/form1.ui b/examples/SQL/form1.ui
new file mode 100644
index 0000000..118a84e
--- /dev/null
+++ b/examples/SQL/form1.ui
@@ -0,0 +1,77 @@
+<!DOCTYPE UI><UI version="3.0" stdsetdef="1">
+<class>Form1</class>
+<widget class="TQDialog">
+ <property name="name">
+ <cstring>Form1</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>600</width>
+ <height>370</height>
+ </rect>
+ </property>
+ <property name="caption">
+ <string>Form1</string>
+ </property>
+ <widget class="TQDataTable">
+ <column>
+ <property name="text">
+ <string>Forename</string>
+ </property>
+ <property name="field">
+ <string>forename</string>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Surname</string>
+ </property>
+ <property name="field">
+ <string>surname</string>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Salary</string>
+ </property>
+ <property name="field">
+ <string>salary</string>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Statusid</string>
+ </property>
+ <property name="field">
+ <string>statusid</string>
+ </property>
+ </column>
+ <property name="name">
+ <cstring>DataTable2</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>600</width>
+ <height>370</height>
+ </rect>
+ </property>
+ <property name="sorting">
+ <bool>true</bool>
+ </property>
+ <property name="confirmDelete">
+ <bool>true</bool>
+ </property>
+ <property name="database" stdset="0">
+ <stringlist>
+ <string>(default)</string>
+ <string>staff</string>
+ </stringlist>
+ </property>
+ </widget>
+</widget>
+<layoutdefaults spacing="6" margin="11"/>
+</UI>
diff --git a/examples/SQL/form2.ui b/examples/SQL/form2.ui
new file mode 100644
index 0000000..4856e39
--- /dev/null
+++ b/examples/SQL/form2.ui
@@ -0,0 +1,327 @@
+<!DOCTYPE UI><UI version="3.0" stdsetdef="1">
+<class>Form2</class>
+<widget class="TQDialog">
+ <property name="name">
+ <cstring>Form2</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>367</width>
+ <height>152</height>
+ </rect>
+ </property>
+ <property name="caption">
+ <string>Form2</string>
+ </property>
+ <widget class="TQDataBrowser">
+ <property name="name">
+ <cstring>DataBrowser1</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>366</width>
+ <height>150</height>
+ </rect>
+ </property>
+ <property name="sort">
+ <stringlist>
+ <string>surname ASC</string>
+ <string>forename ASC</string>
+ </stringlist>
+ </property>
+ <property name="database" stdset="0">
+ <stringlist>
+ <string>(default)</string>
+ <string>staff</string>
+ </stringlist>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>11</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <widget class="TQLayoutWidget" row="0" column="0">
+ <property name="name">
+ <cstring>Layout2</cstring>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <widget class="TQLabel" row="1" column="0">
+ <property name="name">
+ <cstring>labelSurname</cstring>
+ </property>
+ <property name="text">
+ <string>Surname</string>
+ </property>
+ </widget>
+ <widget class="TQSpinBox" row="1" column="3">
+ <property name="name">
+ <cstring>TQSpinBoxStatusid</cstring>
+ </property>
+ <property name="maxValue">
+ <number>2147483647</number>
+ </property>
+ <property name="database" stdset="0">
+ <stringlist>
+ <string>(default)</string>
+ <string>staff</string>
+ <string>statusid</string>
+ </stringlist>
+ </property>
+ </widget>
+ <widget class="TQLineEdit" row="1" column="1">
+ <property name="name">
+ <cstring>TQLineEditSurname</cstring>
+ </property>
+ <property name="database" stdset="0">
+ <stringlist>
+ <string>(default)</string>
+ <string>staff</string>
+ <string>surname</string>
+ </stringlist>
+ </property>
+ </widget>
+ <widget class="TQLabel" row="1" column="2">
+ <property name="name">
+ <cstring>labelStatusid</cstring>
+ </property>
+ <property name="text">
+ <string>Statusid</string>
+ </property>
+ </widget>
+ <widget class="TQLabel" row="0" column="0">
+ <property name="name">
+ <cstring>labelForename</cstring>
+ </property>
+ <property name="text">
+ <string>Forename</string>
+ </property>
+ </widget>
+ <widget class="TQLineEdit" row="0" column="3">
+ <property name="name">
+ <cstring>TQLineEditSalary</cstring>
+ </property>
+ <property name="alignment">
+ <set>AlignRight</set>
+ </property>
+ <property name="database" stdset="0">
+ <stringlist>
+ <string>(default)</string>
+ <string>staff</string>
+ <string>salary</string>
+ </stringlist>
+ </property>
+ </widget>
+ <widget class="TQLabel" row="0" column="2">
+ <property name="name">
+ <cstring>labelSalary</cstring>
+ </property>
+ <property name="text">
+ <string>Salary</string>
+ </property>
+ </widget>
+ <widget class="TQLineEdit" row="0" column="1">
+ <property name="name">
+ <cstring>TQLineEditForename</cstring>
+ </property>
+ <property name="database" stdset="0">
+ <stringlist>
+ <string>(default)</string>
+ <string>staff</string>
+ <string>forename</string>
+ </stringlist>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="TQLayoutWidget" row="1" column="0">
+ <property name="name">
+ <cstring>Layout3</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <widget class="TQPushButton">
+ <property name="name">
+ <cstring>PushButtonFirst</cstring>
+ </property>
+ <property name="text">
+ <string>|&lt; &amp;First</string>
+ </property>
+ </widget>
+ <widget class="TQPushButton">
+ <property name="name">
+ <cstring>PushButtonPrev</cstring>
+ </property>
+ <property name="text">
+ <string>&lt;&lt; &amp;Prev</string>
+ </property>
+ </widget>
+ <widget class="TQPushButton">
+ <property name="name">
+ <cstring>PushButtonNext</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Next &gt;&gt;</string>
+ </property>
+ </widget>
+ <widget class="TQPushButton">
+ <property name="name">
+ <cstring>PushButtonLast</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Last &gt;|</string>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <widget class="TQLayoutWidget" row="2" column="0">
+ <property name="name">
+ <cstring>Layout4</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <widget class="TQPushButton">
+ <property name="name">
+ <cstring>PushButtonInsert</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Insert</string>
+ </property>
+ </widget>
+ <widget class="TQPushButton">
+ <property name="name">
+ <cstring>PushButtonUpdate</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Update</string>
+ </property>
+ </widget>
+ <widget class="TQPushButton">
+ <property name="name">
+ <cstring>PushButtonDelete</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Delete</string>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ </grid>
+ </widget>
+</widget>
+<connections>
+ <connection>
+ <sender>PushButtonFirst</sender>
+ <signal>clicked()</signal>
+ <receiver>DataBrowser1</receiver>
+ <slot>first()</slot>
+ </connection>
+ <connection>
+ <sender>DataBrowser1</sender>
+ <signal>firstRecordAvailable( bool )</signal>
+ <receiver>PushButtonFirst</receiver>
+ <slot>setEnabled(bool)</slot>
+ </connection>
+ <connection>
+ <sender>PushButtonPrev</sender>
+ <signal>clicked()</signal>
+ <receiver>DataBrowser1</receiver>
+ <slot>prev()</slot>
+ </connection>
+ <connection>
+ <sender>DataBrowser1</sender>
+ <signal>prevRecordAvailable( bool )</signal>
+ <receiver>PushButtonPrev</receiver>
+ <slot>setEnabled(bool)</slot>
+ </connection>
+ <connection>
+ <sender>PushButtonNext</sender>
+ <signal>clicked()</signal>
+ <receiver>DataBrowser1</receiver>
+ <slot>next()</slot>
+ </connection>
+ <connection>
+ <sender>DataBrowser1</sender>
+ <signal>nextRecordAvailable( bool )</signal>
+ <receiver>PushButtonNext</receiver>
+ <slot>setEnabled(bool)</slot>
+ </connection>
+ <connection>
+ <sender>PushButtonLast</sender>
+ <signal>clicked()</signal>
+ <receiver>DataBrowser1</receiver>
+ <slot>last()</slot>
+ </connection>
+ <connection>
+ <sender>DataBrowser1</sender>
+ <signal>lastRecordAvailable( bool )</signal>
+ <receiver>PushButtonLast</receiver>
+ <slot>setEnabled(bool)</slot>
+ </connection>
+ <connection>
+ <sender>PushButtonInsert</sender>
+ <signal>clicked()</signal>
+ <receiver>DataBrowser1</receiver>
+ <slot>insert()</slot>
+ </connection>
+ <connection>
+ <sender>PushButtonUpdate</sender>
+ <signal>clicked()</signal>
+ <receiver>DataBrowser1</receiver>
+ <slot>update()</slot>
+ </connection>
+ <connection>
+ <sender>PushButtonDelete</sender>
+ <signal>clicked()</signal>
+ <receiver>DataBrowser1</receiver>
+ <slot>del()</slot>
+ </connection>
+</connections>
+<tabstops>
+ <tabstop>TQLineEditForename</tabstop>
+ <tabstop>TQLineEditSurname</tabstop>
+ <tabstop>TQLineEditSalary</tabstop>
+ <tabstop>TQSpinBoxStatusid</tabstop>
+ <tabstop>PushButtonFirst</tabstop>
+ <tabstop>PushButtonPrev</tabstop>
+ <tabstop>PushButtonNext</tabstop>
+ <tabstop>PushButtonLast</tabstop>
+ <tabstop>PushButtonInsert</tabstop>
+ <tabstop>PushButtonUpdate</tabstop>
+ <tabstop>PushButtonDelete</tabstop>
+</tabstops>
+<layoutdefaults spacing="6" margin="11"/>
+</UI>
diff --git a/examples/SQL/frmconnect.py b/examples/SQL/frmconnect.py
new file mode 100644
index 0000000..97fb406
--- /dev/null
+++ b/examples/SQL/frmconnect.py
@@ -0,0 +1,120 @@
+# Form implementation generated from reading ui file 'frmconnect.ui'
+#
+# Created: Sam Jul 6 12:47:10 2002
+# by: The PyTQt User Interface Compiler (pyuic)
+#
+# WARNING! All changes made in this file will be lost!
+
+
+from python_tqt.qt import *
+
+
+class frmConnect(TQDialog):
+ def __init__(self,parent = None,name = None,modal = 0,fl = 0):
+ TQDialog.__init__(self,parent,name,modal,fl)
+
+ if name == None:
+ self.setName("frmConnect")
+
+ self.resize(415,154)
+ self.setCaption(self.trUtf8("Connecting"))
+ self.setSizeGripEnabled(1)
+
+ frmConnectLayout = TQGridLayout(self,1,1,11,6,"frmConnectLayout")
+
+ Layout7 = TQVBoxLayout(None,0,6,"Layout7")
+
+ self.buttonOK = TQPushButton(self,"buttonOK")
+ self.buttonOK.setText(self.trUtf8("&OK"))
+ self.buttonOK.setAutoDefault(1)
+ self.buttonOK.setDefault(1)
+ TQToolTip.add(self.buttonOK,self.trUtf8("Connect to Database"))
+ Layout7.addWidget(self.buttonOK)
+
+ self.buttonCancel = TQPushButton(self,"buttonCancel")
+ self.buttonCancel.setText(self.trUtf8("&Cancel"))
+ TQToolTip.add(self.buttonCancel,self.trUtf8("Cancel Connecting"))
+ Layout7.addWidget(self.buttonCancel)
+
+ self.buttonHelp = TQPushButton(self,"buttonHelp")
+ self.buttonHelp.setText(self.trUtf8("&Help"))
+ TQToolTip.add(self.buttonHelp,self.trUtf8("About Connecting"))
+ Layout7.addWidget(self.buttonHelp)
+ spacer = TQSpacerItem(0,0,TQSizePolicy.Minimum,TQSizePolicy.Expanding)
+ Layout7.addItem(spacer)
+
+ frmConnectLayout.addLayout(Layout7,0,1)
+
+ self.grpConnection = TQGroupBox(self,"grpConnection")
+ self.grpConnection.setTitle(self.trUtf8(""))
+ self.grpConnection.setColumnLayout(0,TQt.Vertical)
+ self.grpConnection.layout().setSpacing(6)
+ self.grpConnection.layout().setMargin(11)
+ grpConnectionLayout = TQGridLayout(self.grpConnection.layout())
+ grpConnectionLayout.setAlignment(TQt.AlignTop)
+
+ self.txtName = TQLineEdit(self.grpConnection,"txtName")
+ self.txtName.setMaxLength(16)
+ TQToolTip.add(self.txtName,self.trUtf8("Database User ID"))
+
+ grpConnectionLayout.addWidget(self.txtName,0,1)
+
+ self.lblDatabase = TQLabel(self.grpConnection,"lblDatabase")
+ self.lblDatabase.setText(self.trUtf8("&Database"))
+
+ grpConnectionLayout.addWidget(self.lblDatabase,3,0)
+
+ self.lblServer = TQLabel(self.grpConnection,"lblServer")
+ self.lblServer.setText(self.trUtf8("&Server"))
+
+ grpConnectionLayout.addWidget(self.lblServer,2,0)
+
+ self.lblName = TQLabel(self.grpConnection,"lblName")
+ self.lblName.setText(self.trUtf8("&Name"))
+
+ grpConnectionLayout.addWidget(self.lblName,0,0)
+
+ self.cmbDatabase = TQComboBox(0,self.grpConnection,"cmbDatabase")
+ self.cmbDatabase.setEditable(1)
+ self.cmbDatabase.setAutoCompletion(1)
+ self.cmbDatabase.setDuplicatesEnabled(0)
+ TQToolTip.add(self.cmbDatabase,self.trUtf8("Database Name"))
+
+ grpConnectionLayout.addWidget(self.cmbDatabase,3,1)
+
+ self.txtPasswd = TQLineEdit(self.grpConnection,"txtPasswd")
+ self.txtPasswd.setMaxLength(16)
+ self.txtPasswd.setEchoMode(TQLineEdit.Password)
+ TQToolTip.add(self.txtPasswd,self.trUtf8("Database User Password"))
+
+ grpConnectionLayout.addWidget(self.txtPasswd,1,1)
+
+ self.lblPasswd = TQLabel(self.grpConnection,"lblPasswd")
+ self.lblPasswd.setText(self.trUtf8("&Password"))
+
+ grpConnectionLayout.addWidget(self.lblPasswd,1,0)
+
+ self.cmbServer = TQComboBox(0,self.grpConnection,"cmbServer")
+ self.cmbServer.setEditable(1)
+ self.cmbServer.setAutoCompletion(1)
+ self.cmbServer.setDuplicatesEnabled(0)
+ TQToolTip.add(self.cmbServer,self.trUtf8("Database Server Address"))
+
+ grpConnectionLayout.addWidget(self.cmbServer,2,1)
+
+ frmConnectLayout.addWidget(self.grpConnection,0,0)
+
+ self.connect(self.buttonOK,SIGNAL("clicked()"),self,SLOT("accept()"))
+ self.connect(self.buttonCancel,SIGNAL("clicked()"),self,SLOT("reject()"))
+
+ self.setTabOrder(self.txtName,self.txtPasswd)
+ self.setTabOrder(self.txtPasswd,self.cmbServer)
+ self.setTabOrder(self.cmbServer,self.cmbDatabase)
+ self.setTabOrder(self.cmbDatabase,self.buttonOK)
+ self.setTabOrder(self.buttonOK,self.buttonCancel)
+ self.setTabOrder(self.buttonCancel,self.buttonHelp)
+
+ self.lblDatabase.setBuddy(self.cmbDatabase)
+ self.lblServer.setBuddy(self.cmbServer)
+ self.lblName.setBuddy(self.txtName)
+ self.lblPasswd.setBuddy(self.txtPasswd)
diff --git a/examples/SQL/frmconnect.ui b/examples/SQL/frmconnect.ui
new file mode 100644
index 0000000..f2017ee
--- /dev/null
+++ b/examples/SQL/frmconnect.ui
@@ -0,0 +1,245 @@
+<!DOCTYPE UI><UI version="3.0" stdsetdef="1">
+<class>frmConnect</class>
+<widget class="TQDialog">
+ <property name="name">
+ <cstring>frmConnect</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>415</width>
+ <height>154</height>
+ </rect>
+ </property>
+ <property name="caption">
+ <string>Connecting</string>
+ </property>
+ <property name="sizeGripEnabled">
+ <bool>true</bool>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>11</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <widget class="TQLayoutWidget" row="0" column="1">
+ <property name="name">
+ <cstring>Layout7</cstring>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <widget class="TQPushButton">
+ <property name="name">
+ <cstring>buttonOK</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;OK</string>
+ </property>
+ <property name="autoDefault">
+ <bool>true</bool>
+ </property>
+ <property name="default">
+ <bool>true</bool>
+ </property>
+ <property name="toolTip" stdset="0">
+ <string>Connect to Database</string>
+ </property>
+ </widget>
+ <widget class="TQPushButton">
+ <property name="name">
+ <cstring>buttonCancel</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Cancel</string>
+ </property>
+ <property name="toolTip" stdset="0">
+ <string>Cancel Connecting</string>
+ </property>
+ </widget>
+ <widget class="TQPushButton">
+ <property name="name">
+ <cstring>buttonHelp</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Help</string>
+ </property>
+ <property name="toolTip" stdset="0">
+ <string>About Connecting</string>
+ </property>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>spacer</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ </spacer>
+ </vbox>
+ </widget>
+ <widget class="TQGroupBox" row="0" column="0">
+ <property name="name">
+ <cstring>grpConnection</cstring>
+ </property>
+ <property name="title">
+ <string></string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>11</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <widget class="TQLineEdit" row="0" column="1">
+ <property name="name">
+ <cstring>txtName</cstring>
+ </property>
+ <property name="maxLength">
+ <number>16</number>
+ </property>
+ <property name="toolTip" stdset="0">
+ <string>Database User ID</string>
+ </property>
+ </widget>
+ <widget class="TQLabel" row="3" column="0">
+ <property name="name">
+ <cstring>lblDatabase</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Database</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>cmbDatabase</cstring>
+ </property>
+ </widget>
+ <widget class="TQLabel" row="2" column="0">
+ <property name="name">
+ <cstring>lblServer</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Server</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>cmbServer</cstring>
+ </property>
+ </widget>
+ <widget class="TQLabel" row="0" column="0">
+ <property name="name">
+ <cstring>lblName</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Name</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>txtName</cstring>
+ </property>
+ </widget>
+ <widget class="TQComboBox" row="3" column="1">
+ <property name="name">
+ <cstring>cmbDatabase</cstring>
+ </property>
+ <property name="editable">
+ <bool>true</bool>
+ </property>
+ <property name="autoCompletion">
+ <bool>true</bool>
+ </property>
+ <property name="duplicatesEnabled">
+ <bool>false</bool>
+ </property>
+ <property name="toolTip" stdset="0">
+ <string>Database Name</string>
+ </property>
+ </widget>
+ <widget class="TQLineEdit" row="1" column="1">
+ <property name="name">
+ <cstring>txtPasswd</cstring>
+ </property>
+ <property name="maxLength">
+ <number>16</number>
+ </property>
+ <property name="echoMode">
+ <enum>Password</enum>
+ </property>
+ <property name="toolTip" stdset="0">
+ <string>Database User Password</string>
+ </property>
+ </widget>
+ <widget class="TQLabel" row="1" column="0">
+ <property name="name">
+ <cstring>lblPasswd</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Password</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>txtPasswd</cstring>
+ </property>
+ </widget>
+ <widget class="TQComboBox" row="2" column="1">
+ <property name="name">
+ <cstring>cmbServer</cstring>
+ </property>
+ <property name="editable">
+ <bool>true</bool>
+ </property>
+ <property name="autoCompletion">
+ <bool>true</bool>
+ </property>
+ <property name="duplicatesEnabled">
+ <bool>false</bool>
+ </property>
+ <property name="toolTip" stdset="0">
+ <string>Database Server Address</string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ </grid>
+</widget>
+<connections>
+ <connection>
+ <sender>buttonOK</sender>
+ <signal>clicked()</signal>
+ <receiver>frmConnect</receiver>
+ <slot>accept()</slot>
+ </connection>
+ <connection>
+ <sender>buttonCancel</sender>
+ <signal>clicked()</signal>
+ <receiver>frmConnect</receiver>
+ <slot>reject()</slot>
+ </connection>
+</connections>
+<tabstops>
+ <tabstop>txtName</tabstop>
+ <tabstop>txtPasswd</tabstop>
+ <tabstop>cmbServer</tabstop>
+ <tabstop>cmbDatabase</tabstop>
+ <tabstop>buttonOK</tabstop>
+ <tabstop>buttonCancel</tabstop>
+ <tabstop>buttonHelp</tabstop>
+</tabstops>
+<layoutdefaults spacing="6" margin="11"/>
+</UI>
diff --git a/examples/SQL/runform1.py b/examples/SQL/runform1.py
new file mode 100755
index 0000000..2e01b7e
--- /dev/null
+++ b/examples/SQL/runform1.py
@@ -0,0 +1,21 @@
+#!/usr/bin/env python
+
+import sys
+from python_tqt.qt import *
+
+from form1 import Form1
+from dbconnect import createConnection
+
+class mainWindow(Form1):
+ def __init__(self,parent = None,name = None,fl = 0):
+ Form1.__init__(self,parent,name,fl)
+
+if __name__ == "__main__":
+ a = TQApplication(sys.argv)
+ if createConnection():
+ TQObject.connect(a,SIGNAL("lastWindowClosed()"),a,SLOT("quit()"))
+ w = mainWindow()
+ a.setMainWidget(w)
+ w.show()
+ a.exec_loop()
+
diff --git a/examples/SQL/runform2.py b/examples/SQL/runform2.py
new file mode 100755
index 0000000..0184e9d
--- /dev/null
+++ b/examples/SQL/runform2.py
@@ -0,0 +1,21 @@
+#!/usr/bin/env python
+
+import sys
+from python_tqt.qt import *
+
+from form2 import Form2
+from dbconnect import createConnection
+
+class mainWindow(Form2):
+ def __init__(self,parent = None,name = None,fl = 0):
+ Form2.__init__(self,parent,name,fl)
+
+if __name__ == "__main__":
+ a = TQApplication(sys.argv)
+ if createConnection():
+ TQObject.connect(a,SIGNAL("lastWindowClosed()"),a,SLOT("quit()"))
+ w = mainWindow()
+ a.setMainWidget(w)
+ w.show()
+ a.exec_loop()
+
diff --git a/examples/SQL/runsqlex.py b/examples/SQL/runsqlex.py
new file mode 100755
index 0000000..2235699
--- /dev/null
+++ b/examples/SQL/runsqlex.py
@@ -0,0 +1,151 @@
+#!/usr/bin/env python
+
+import sys
+from python_tqt.qt import *
+from python_tqt.qtsql import *
+
+from sqlex import SqlEx
+from connect import ConnectDialog
+
+from dbpar import *
+
+TRUE = 1
+FALSE = 0
+
+def showError(err, parent):
+ errStr = TQString("The database reported an error:\n\n")
+ if not err.databaseText().isEmpty():
+ errStr.append(err.databaseText())
+ errStr.append("\n")
+ if not err.driverText().isEmpty():
+ errStr.append(err.driverText())
+ errStr.append("\n")
+ TQMessageBox.warning(parent, "Error", errStr)
+
+class CustomSqlCursor(TQSqlCursor):
+ def __init__(self, query = None, autopopulate = TRUE, db = None):
+ TQSqlCursor.__init__(self, None, autopopulate, db)
+ self.execQuery(query)
+ if self.isSelect() and autopopulate:
+ fields = self.driver().recordInfo(self)
+ for f in fields:
+ self.append(f)
+ self.setMode(TQSqlCursor.ReadOnly)
+
+ def select(self, filter, sort = TQSqlIndex()):
+ return self.execQuery(self.lastQuery())
+
+ def primaryIndex(self, prime = TRUE):
+ return TQSqlIndex()
+
+ def insert(self, invalidate = TRUE):
+ return FALSE
+
+ def update(self, invalidate = TRUE):
+ return FALSE
+
+ def delRecords(self, invalidate = TRUE):
+ return FALSE
+
+ def setName(self, name, autopopulate = TRUE):
+ return
+
+
+class MainWindow(SqlEx):
+ def __init__(self,parent = None,name = None,fl = 0):
+ SqlEx.__init__(self,parent,name,fl)
+ self.conDiag = ConnectDialog(self, "Connection Dialog", TRUE)
+ self.firstconn = TRUE
+
+ def dbConnect(self):
+ if self.firstconn:
+ self.firstconn = FALSE
+ self.conDiag.editUsername.setText(DB_USERNAME)
+ self.conDiag.editPassword.setText(DB_PASSWORD)
+ self.conDiag.editHostname.setText(DB_HOSTNAMES[0])
+ self.conDiag.editDatabase.setText(DB_DATABASES[0])
+ for i in range(self.conDiag.comboDriver.count()):
+ if str(self.conDiag.comboDriver.text(i)) == DB_DRIVER:
+ self.conDiag.comboDriver.setCurrentItem(i)
+ break
+ if self.conDiag.exec_loop() != TQDialog.Accepted:
+ return
+ if self.dt.sqlCursor():
+ self.dt.setSqlCursor()
+
+ # close old connection (if any)
+ if TQSqlDatabase.contains("SqlEx"):
+ oldDb = TQSqlDatabase.database("SqlEx")
+ oldDb.close()
+ TQSqlDatabase.removeDatabase("SqlEx")
+
+ # open the new connection
+ db = TQSqlDatabase.addDatabase(self.conDiag.comboDriver.currentText(), "SqlEx")
+ if not db:
+ TQMessageBox.warning(self, "Error", "Could not open database")
+ return
+
+ db.setHostName(self.conDiag.editHostname.text())
+ db.setDatabaseName(self.conDiag.editDatabase.text())
+ db.setPort(self.conDiag.portSpinBox.value())
+ if not db.open(self.conDiag.editUsername.text(),
+ self.conDiag.editPassword.text()):
+ showError(db.lastError(), self)
+ return
+
+ self.lbl.setText("Double-Click on a table-name to view the contents")
+ self.lv.clear()
+
+ tables = db.tables()
+ for t in tables:
+ lvi = TQListViewItem(self.lv, t)
+ fields = db.recordInfo(t)
+ for f in fields:
+ req = "?"
+ if f.isRequired() > 0:
+ req = "Yes"
+ elif f.isRequired() == 0:
+ req = "No"
+ fi = TQListViewItem(lvi, f.name(), TQVariant.typeToName(f.type()), req)
+ lvi.insertItem(fi)
+ self.lv.insertItem(lvi)
+
+ self.submitBtn.setEnabled(TRUE)
+
+ def execQuery(self):
+ cursor = CustomSqlCursor(self.te.text(), TRUE,
+ TQSqlDatabase.database("SqlEx", TRUE))
+ if cursor.isSelect():
+ self.dt.setSqlCursor(cursor, TRUE, TRUE)
+ self.dt.refresh()
+ txt = TQString("Query OK")
+ if cursor.size() >= 0:
+ txt.append(", returned rows: %s" % cursor.size())
+ self.lbl.setText(txt)
+ else:
+ if not cursor.isActive():
+ # an error occured
+ showError(cursor.lastError(), self)
+ else:
+ self.lbl.setText("Query OK, affected rows: %s" %
+ cursor.numRowsAffected())
+
+ def showTable(self, item):
+ i = item.parent()
+ if not i:
+ i = item
+ cursor = TQSqlCursor(i.text(0), TRUE, TQSqlDatabase.database("SqlEx", TRUE))
+ self.dt.setSqlCursor(cursor, TRUE, TRUE)
+ self.dt.setSort(cursor.primaryIndex())
+ self.dt.refresh(TQDataTable.RefreshAll)
+ self.lbl.setText("Displaying table %s" % i.text(0))
+
+
+if __name__ == "__main__":
+ a = TQApplication(sys.argv)
+ TQObject.connect(a,SIGNAL("lastWindowClosed()"),a,SLOT("quit()"))
+ w = MainWindow()
+ a.setMainWidget(w)
+ w.show()
+ a.exec_loop()
+
diff --git a/examples/SQL/sqlcustom1.py b/examples/SQL/sqlcustom1.py
new file mode 100755
index 0000000..4da8f8a
--- /dev/null
+++ b/examples/SQL/sqlcustom1.py
@@ -0,0 +1,94 @@
+#!/usr/bin/env python
+
+#****************************************************************************
+#** $Id: sqlcustom1.py,v 1.3 2002/07/06 13:35:41 phil Exp $
+#**
+#** Copyright (C) 1992-1998 Troll Tech AS. All rights reserved.
+#**
+#** This file is part of an example program for PyTQt. This example
+#** program may be used, distributed and modified without limitation.
+#**
+#*****************************************************************************/
+
+import sys
+from python_tqt.qt import *
+from python_tqt.qtsql import *
+
+from dbconnect import createConnection
+
+TRUE = 1
+FALSE = 0
+
+class CustomEdit(TQLineEdit):
+ def __init__(self, parent = None, name = None):
+ TQLineEdit.__init__(self, parent, name)
+ TQObject.connect(self, SIGNAL("textChanged(const TQString &)"),
+ self.changed)
+
+ def changed(self, line):
+ self.setUpperLine(line)
+
+ def setUpperLine(self, line):
+ self.upperLineText = line.upper()
+ self.setText(self.upperLineText)
+
+
+class FormDialog(TQDialog):
+ def __init__(self):
+ TQDialog.__init__(self)
+ forenameLabel = TQLabel("Forename:", self)
+ forenameEdit = CustomEdit(self)
+ surnameLabel = TQLabel("Surname:", self)
+ surnameEdit = CustomEdit(self)
+ salaryLabel = TQLabel("Salary:", self)
+ salaryEdit = TQLineEdit(self)
+ salaryEdit.setAlignment(TQt.AlignRight)
+ saveButton = TQPushButton("&Save", self)
+ self.connect(saveButton, SIGNAL("clicked()"), self.save)
+
+ grid = TQGridLayout(self)
+ grid.addWidget(forenameLabel, 0, 0)
+ grid.addWidget(forenameEdit, 0, 1)
+ grid.addWidget(surnameLabel, 1, 0)
+ grid.addWidget(surnameEdit, 1, 1)
+ grid.addWidget(salaryLabel, 2, 0)
+ grid.addWidget(salaryEdit, 2, 1)
+ grid.addWidget(saveButton, 3, 0)
+ grid.activate()
+
+ self.staffCursor = TQSqlCursor("staff")
+ self.staffCursor.setTrimmed("forename", TRUE)
+ self.staffCursor.setTrimmed("surname", TRUE)
+ self.idIndex = self.staffCursor.index("id")
+ self.staffCursor.select(self.idIndex)
+ self.staffCursor.first()
+
+ self.propMap = TQSqlPropertyMap()
+ self.propMap.insert(forenameEdit.className(), "upperLine")
+
+ self.sqlForm = TQSqlForm()
+ self.sqlForm.setRecord(self.staffCursor.primeUpdate())
+ self.sqlForm.installPropertyMap(self.propMap)
+ self.sqlForm.insert(forenameEdit, "forename")
+ self.sqlForm.insert(surnameEdit, "surname")
+ self.sqlForm.insert(salaryEdit, "salary")
+ self.sqlForm.readFields()
+
+ def save(self):
+ self.sqlForm.writeFields()
+ self.staffCursor.update()
+ self.staffCursor.select(self.idIndex)
+ self.staffCursor.first()
+
+
+if __name__=='__main__':
+ app = TQApplication( sys.argv )
+
+ if createConnection():
+ formDialog = FormDialog()
+ formDialog.show()
+
+ app.setMainWidget(formDialog)
+ app.exec_loop()
+
+
diff --git a/examples/SQL/sqlex.ui b/examples/SQL/sqlex.ui
new file mode 100644
index 0000000..64b3d0f
--- /dev/null
+++ b/examples/SQL/sqlex.ui
@@ -0,0 +1,303 @@
+<!DOCTYPE UI><UI version="3.0" stdsetdef="1">
+<class>SqlEx</class>
+<widget class="TQWidget">
+ <property name="name">
+ <cstring>SqlEx</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>669</width>
+ <height>438</height>
+ </rect>
+ </property>
+ <property name="caption">
+ <string>SQL Browser</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>11</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <widget class="TQLayoutWidget" row="1" column="0">
+ <property name="name">
+ <cstring>Layout23</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <widget class="TQLabel">
+ <property name="name">
+ <cstring>lbl</cstring>
+ </property>
+ <property name="text">
+ <string>Press "Connect" to open a database</string>
+ </property>
+ </widget>
+ <widget class="TQPushButton">
+ <property name="name">
+ <cstring>conBtn</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>0</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>80</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="text">
+ <string>&amp;Connect...</string>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <widget class="TQSplitter" row="0" column="0">
+ <property name="name">
+ <cstring>vsplit</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <widget class="TQSplitter">
+ <property name="name">
+ <cstring>hsplit</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <widget class="TQListView">
+ <column>
+ <property name="text">
+ <string>Tables</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizeable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Type</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizeable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Required</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizeable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <property name="name">
+ <cstring>lv</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <property name="allColumnsShowFocus">
+ <bool>true</bool>
+ </property>
+ <property name="rootIsDecorated">
+ <bool>true</bool>
+ </property>
+ <property name="resizeMode">
+ <enum>LastColumn</enum>
+ </property>
+ </widget>
+ <widget class="TQDataTable">
+ <property name="name">
+ <cstring>dt</cstring>
+ </property>
+ <property name="frameworkCode" stdset="0">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </widget>
+ <widget class="TQGroupBox">
+ <property name="name">
+ <cstring>gb</cstring>
+ </property>
+ <property name="title">
+ <string>SQL Query</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>11</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <widget class="TQLayoutWidget" row="0" column="0">
+ <property name="name">
+ <cstring>Layout22</cstring>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <widget class="TQTextEdit">
+ <property name="name">
+ <cstring>te</cstring>
+ </property>
+ </widget>
+ <widget class="TQLayoutWidget">
+ <property name="name">
+ <cstring>Layout21</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <spacer>
+ <property name="name">
+ <cstring>Spacer3</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ </spacer>
+ <widget class="TQPushButton">
+ <property name="name">
+ <cstring>submitBtn</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>80</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="text">
+ <string>&amp;Submit</string>
+ </property>
+ </widget>
+ <widget class="TQPushButton">
+ <property name="name">
+ <cstring>clearBtn</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>80</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="text">
+ <string>C&amp;lear</string>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ </vbox>
+ </widget>
+ </grid>
+ </widget>
+ </widget>
+ </grid>
+</widget>
+<connections>
+ <connection>
+ <sender>clearBtn</sender>
+ <signal>clicked()</signal>
+ <receiver>te</receiver>
+ <slot>clear()</slot>
+ </connection>
+ <connection>
+ <sender>conBtn</sender>
+ <signal>clicked()</signal>
+ <receiver>SqlEx</receiver>
+ <slot>dbConnect()</slot>
+ </connection>
+ <connection>
+ <sender>lv</sender>
+ <signal>returnPressed(TQListViewItem*)</signal>
+ <receiver>SqlEx</receiver>
+ <slot>showTable(TQListViewItem*)</slot>
+ </connection>
+ <connection>
+ <sender>lv</sender>
+ <signal>doubleClicked(TQListViewItem*)</signal>
+ <receiver>SqlEx</receiver>
+ <slot>showTable(TQListViewItem*)</slot>
+ </connection>
+ <connection>
+ <sender>submitBtn</sender>
+ <signal>clicked()</signal>
+ <receiver>SqlEx</receiver>
+ <slot>execQuery()</slot>
+ </connection>
+</connections>
+<includes>
+ <include location="local" impldecl="in implementation">sqlex.ui.h</include>
+</includes>
+<slots>
+ <slot>init()</slot>
+ <slot>dbConnect()</slot>
+ <slot>showTable( TQListViewItem * )</slot>
+ <slot>execQuery()</slot>
+</slots>
+<layoutdefaults spacing="6" margin="11"/>
+</UI>
diff --git a/examples/SQL/sqlex.ui.h b/examples/SQL/sqlex.ui.h
new file mode 100644
index 0000000..07edcd0
--- /dev/null
+++ b/examples/SQL/sqlex.ui.h
@@ -0,0 +1,35 @@
+/****************************************************************************
+** ui.h extension file, included from the uic-generated form implementation.
+**
+** If you wish to add, delete or rename slots use TQt Designer which will
+** update this file, preserving your code. Create an init() slot in place of
+** a constructor, and a destroy() slot in place of a destructor.
+*****************************************************************************/
+
+
+void SqlEx::init()
+{
+self.hsplit.setSizes([250])
+self.hsplit.setResizeMode(self.lv, TQSplitter.KeepSize)
+self.vsplit.setResizeMode(self.gb, TQSplitter.KeepSize)
+self.submitBtn.setEnabled(0)
+}
+
+
+void SqlEx::dbConnect()
+{
+
+}
+
+
+void SqlEx::showTable( TQListViewItem * )
+{
+
+}
+
+
+
+void SqlEx::execQuery()
+{
+
+}
diff --git a/examples/SQL/sqlsubclass5.py b/examples/SQL/sqlsubclass5.py
new file mode 100755
index 0000000..0fdc78c
--- /dev/null
+++ b/examples/SQL/sqlsubclass5.py
@@ -0,0 +1,151 @@
+#!/usr/bin/env python
+
+#****************************************************************************
+#** $Id: sqlsubclass5.py,v 1.3 2002/07/06 13:35:41 phil Exp $
+#**
+#** Copyright (C) 1992-1998 Troll Tech AS. All rights reserved.
+#**
+#** This file is part of an example program for PyTQt. This example
+#** program may be used, distributed and modified without limitation.
+#**
+#*****************************************************************************/
+
+import sys
+from python_tqt.qt import *
+from python_tqt.qtsql import *
+
+from dbconnect import createConnection
+
+TRUE = 1
+FALSE = 0
+
+class CustomTable(TQDataTable):
+ def __init__(self, cursor, autoPopulate = FALSE, parent = None, name = None):
+ TQDataTable.__init__(self, cursor, autoPopulate, parent, name)
+
+ def paintField(self, p, field, cr, b):
+ if not field:
+ return
+ fn = str(field.name())
+ if fn == "pricesid":
+ query = TQSqlQuery("SELECT name FROM prices WHERE id=%s" %
+ field.value().toString())
+ value = ""
+ if next(query):
+ value = query.value(0).toString()
+ p.drawText(2, 2, cr.width()-4, cr.height()-4,
+ self.fieldAlignment(field), value)
+ elif fn == "quantity":
+ p.drawText(2, 2, cr.width()-6, cr.height()-4,
+ TQt.AlignRight|TQt.AlignVCenter, field.value().toString())
+ elif fn in ("price", "cost"):
+ v = field.value().toDouble()
+ if v < 0:
+ p.setPen(TQColor("red"))
+ value = TQString("%.2f \u20ac" % v)
+ p.drawText(2, 2, cr.width()-6, cr.height()-4,
+ TQt.AlignRight|TQt.AlignVCenter, value)
+ elif fn == "paiddate":
+ if field.value().toDate().isNull():
+ v = TQString("not yet")
+ p.setPen(TQColor("red"))
+ else:
+ v = field.value().toDate().toString(TQt.LocalDate)
+ p.drawText(2, 2, cr.width()-4, cr.height()-4,
+ TQt.AlignHCenter|TQt.AlignVCenter, v)
+ else:
+ TQDataTable.paintField(self, p, field, cr, b)
+
+
+class InvoiceItemCursor(TQSqlCursor):
+ def __init__(self):
+ TQSqlCursor.__init__(self, "invoiceitem")
+
+ productPrice = TQSqlFieldInfo("price", TQVariant.Double)
+ self.append(productPrice)
+ self.setCalculated(productPrice.name(), TRUE)
+
+ productCost = TQSqlFieldInfo("cost", TQVariant.Double)
+ self.append(productCost)
+ self.setCalculated(productCost.name(), TRUE)
+
+ def calculateField(self, name):
+ fn = str(name)
+ if fn == "productname":
+ query = TQSqlQuery("SELECT name FROM prices WHERE id=%d;" %
+ (self.field("pricesid").value().toInt()))
+ if next(query):
+ return query.value(0)
+ elif fn == "price":
+ query = TQSqlQuery("SELECT price FROM prices WHERE id=%d;" %
+ (self.field("pricesid").value().toInt()))
+ if next(query):
+ return query.value(0)
+ elif fn == "cost":
+ query = TQSqlQuery("SELECT price FROM prices WHERE id=%d;" %
+ (self.field("pricesid").value().toInt()))
+ if next(query):
+ return TQVariant(query.value(0).toDouble() *
+ self.value("quantity").toDouble())
+ return TQVariant(TQString.null)
+
+ def primeInsert(self):
+ buffer = self.editBuffer()
+ buffer.setValue("id", TQVariant(0))
+ buffer.setValue("paiddate", TQVariant(TQDate.currentDate()))
+ buffer.setValue("quantity", TQVariant(1))
+ return buffer
+
+
+class ProductPicker(TQComboBox):
+ def __init__(self, parent = None, name = None):
+ TQComboBox.__init__(self, parent, name)
+ cur = TQSqlCursor("prices")
+ cur.select(cur.index("id"))
+ while next(cur):
+ self.insertItem(cur.value("name").toString(), cur.value("id").toInt())
+
+
+class CustomSqlEditorFactory(TQSqlEditorFactory):
+ def __init__(self):
+ TQSqlEditorFactory.__init__(self)
+
+ def createEditor(self, parent, field):
+ try:
+ if str(field.name()) == "pricesid":
+ return ProductPicker(parent)
+ except AttributeError:
+ pass
+ return TQSqlEditorFactory.createEditor(self, parent, field)
+
+class Table(CustomTable):
+ def __init__(self):
+ self.invoiceItemCursor = InvoiceItemCursor()
+ TQDataTable.__init__(self, self.invoiceItemCursor)
+ self.propMap = TQSqlPropertyMap()
+ self.editorFactory = CustomSqlEditorFactory()
+ self.propMap.insert("ProductPicker", "pricesid")
+ self.installPropertyMap(self.propMap)
+ self.installEditorFactory(self.editorFactory)
+
+ for cn, ch in (("pricesid", "Product"),
+ ("quantity", "Quantity"),
+ ("price", "Price" ),
+ ("cost", "Cost"),
+ ("paiddate", "Paid")):
+ self.addColumn(cn, ch)
+ self.setColumnWidth(0 , 150)
+ self.setColumnWidth(1, 70)
+ self.resize(600, 250)
+ self.refresh()
+
+
+if __name__=='__main__':
+ app = TQApplication(sys.argv)
+ if createConnection():
+ t = Table()
+ app.setMainWidget(t)
+ t.show()
+ app.exec_loop()
+
+
diff --git a/examples/SQL/sqltable4.py b/examples/SQL/sqltable4.py
new file mode 100755
index 0000000..a8484c5
--- /dev/null
+++ b/examples/SQL/sqltable4.py
@@ -0,0 +1,118 @@
+#!/usr/bin/env python
+
+#****************************************************************************
+#** $Id: sqltable4.py,v 1.3 2002/07/06 13:35:41 phil Exp $
+#**
+#** Copyright (C) 1992-1998 Troll Tech AS. All rights reserved.
+#**
+#** This file is part of an example program for PyTQt. This example
+#** program may be used, distributed and modified without limitation.
+#**
+#*****************************************************************************/
+
+import sys
+from python_tqt.qt import *
+from python_tqt.qtsql import *
+
+from dbconnect import createConnection
+
+TRUE = 1
+FALSE = 0
+
+class CustomTable(TQDataTable):
+ def __init__(self, cursor, autoPopulate = FALSE, parent = None, name = None):
+ TQDataTable.__init__(self, cursor, autoPopulate, parent, name)
+
+ def paintField(self, p, field, cr, b):
+ if not field:
+ return
+ fn = str(field.name())
+ if fn in ("salary", "monsalary"):
+ v = field.value().toDouble()
+ if v < 0:
+ p.setPen(TQColor("red"))
+ value = TQString("%.2f \u20ac" % v)
+ #print unicode(value).encode("iso-8859-15")
+ p.drawText(2, 2, cr.width()-6, cr.height()-4,
+ TQt.AlignRight|TQt.AlignVCenter, value)
+ elif fn == "statusid":
+ query = TQSqlQuery("SELECT name FROM status WHERE id=%s" %
+ field.value().toString())
+ value = ""
+ if next(query):
+ value = query.value(0).toString()
+ p.drawText(2, 2, cr.width()-4, cr.height()-4,
+ self.fieldAlignment(field), value)
+ else:
+ TQDataTable.paintField(self, p, field, cr, b)
+
+
+class StatusPicker(TQComboBox):
+ def __init__(self, parent = None, name = None):
+ TQComboBox.__init__(self, parent, name)
+ cur = TQSqlCursor("status")
+ cur.select(cur.index("id"))
+ while next(cur):
+ self.insertItem(cur.value("name").toString(), cur.value("id").toInt())
+
+
+class CustomSqlEditorFactory(TQSqlEditorFactory):
+ def __init__(self):
+ TQSqlEditorFactory.__init__(self)
+
+ def createEditor(self, parent, field):
+ try:
+ if str(field.name()) == "statusid":
+ return StatusPicker(parent)
+ except AttributeError:
+ pass
+ return TQSqlEditorFactory.createEditor(self, parent, field)
+
+
+class StaffCursor(TQSqlCursor):
+ def __init__(self):
+ TQSqlCursor.__init__(self, "staff")
+ monSalary = TQSqlFieldInfo("monsalary", TQVariant.Double)
+ self.append(monSalary)
+ self.setCalculated(monSalary.name(), TRUE)
+
+ def calculateField(self, name):
+ if str(name) == "monsalary":
+ return TQVariant(self.value("salary").toDouble() / 12)
+ return TQVariant(TQString.null)
+
+
+class Table(CustomTable):
+ def __init__(self):
+ #self.staffCursor = TQSqlCursor("staff")
+ self.staffCursor = StaffCursor()
+ TQDataTable.__init__(self, self.staffCursor)
+ self.propMap = TQSqlPropertyMap()
+ self.editorFactory = CustomSqlEditorFactory()
+ self.propMap.insert("StatusPicker", "statusid")
+ self.installPropertyMap(self.propMap)
+ self.installEditorFactory(self.editorFactory)
+ for cn, ch in (("forename", "Forename"),
+ ("surname", "Surname" ),
+ ("salary", "Annual Salary"),
+ ("monsalary","Monthly Salary"),
+ ("statusid", "Status")):
+ self.addColumn(cn, ch)
+ self.order = TQStringList("surname")
+ self.order.append("forename")
+ self.setSort(self.order)
+ self.refresh()
+
+
+if __name__=='__main__':
+ app = TQApplication(sys.argv)
+ #app.setFont(TQFont("Verdana", 11))
+
+ if createConnection():
+ t = Table()
+ app.setMainWidget(t)
+ t.resize(600, 250)
+ t.show()
+ app.exec_loop()
+
+
diff --git a/examples/SQL/testdb_mysql.sql b/examples/SQL/testdb_mysql.sql
new file mode 100644
index 0000000..144d4c9
--- /dev/null
+++ b/examples/SQL/testdb_mysql.sql
@@ -0,0 +1,57 @@
+drop database testdb;
+create database testdb;
+use testdb;
+
+create table people (id integer primary key auto_increment,
+ name char(40));
+
+create table staff (id integer primary key auto_increment,
+ forename char(40),
+ surname char(40),
+ salary float(10,2),
+ statusid integer);
+
+create table status (id integer primary key,
+ name char(30));
+
+create table creditors (id integer primary key auto_increment,
+ forename char(40),
+ surname char(40),
+ city char(30));
+
+create table prices (id integer primary key,
+ name char(40),
+ price float);
+
+create table invoiceitem (id integer primary key auto_increment,
+ pricesid integer,
+ quantity integer,
+ paiddate date);
+
+insert into staff (forename, surname, salary, statusid) values
+ ("Hugo", "Hurtig", 123450.50, 0),
+ ("Alfred E.", "Neumann", 56780.90, 1),
+ ("Agate", "Schnell-Fertig", 12340.56, 2),
+ ("Emil", "Dotterschreck", -5670.23, 3),
+ ("Eugen", "Nutzlos", -7833.56, 3),
+ ("Harald", "Schmidt", -150000.0, 3),
+ ("Urmel", "auf dem Eis", 7778.0, 2);
+
+insert into status (id, name) values
+ (0, 'Chief'),
+ (1, 'Programmer'),
+ (2, 'Secretary'),
+ (3, 'Driver');
+
+insert into prices (id, name, price) values
+ (0, "Waschbecken", 150.25),
+ (1, "Wellensittich", 27.95),
+ (2, "Roter Papagei", 850.0),
+ (3, "Spam & Eggs", -7.50),
+ (4, "Renault Espace", 9000.0),
+ (5, "Tux, der Pinguin", 65.35),
+ (6, "Makroskop", 985000.0),
+ (7, "Regenbaum", 1235.65),
+ (8, "Bluterguß", 23.95),
+ (9, "Weltmeisterschaft", 2.95),
+ (10, "Premiere Dekoder", -185.75);
diff --git a/examples/SQL/testdb_pg.sql b/examples/SQL/testdb_pg.sql
new file mode 100644
index 0000000..73a4270
--- /dev/null
+++ b/examples/SQL/testdb_pg.sql
@@ -0,0 +1,232 @@
+--
+-- Selected TOC Entries:
+--
+--
+-- TOC Entry ID 1 (OID 0)
+--
+-- Name: testdb Type: DATABASE Owner: postgres
+--
+
+CREATE DATABASE "testdb";
+
+\connect testdb postgres
+--
+-- TOC Entry ID 16 (OID 17332)
+--
+-- Name: people Type: TABLE Owner: postgres
+--
+
+CREATE TABLE "people" (
+ "id" integer DEFAULT nextval('people_id_seq'::text) NOT NULL,
+ "name" character(40),
+ Constraint "people_pkey" Primary Key ("id")
+);
+
+--
+-- TOC Entry ID 17 (OID 17335)
+--
+-- Name: staff Type: TABLE Owner: postgres
+--
+
+CREATE TABLE "staff" (
+ "id" integer DEFAULT nextval('staff_id_seq'::text) NOT NULL,
+ "forename" character(40),
+ "surname" character(40),
+ "salary" money,
+ "statusid" integer,
+ Constraint "staff_pkey" Primary Key ("id")
+);
+
+--
+-- TOC Entry ID 18 (OID 17338)
+--
+-- Name: status Type: TABLE Owner: postgres
+--
+
+CREATE TABLE "status" (
+ "id" integer NOT NULL,
+ "name" character(30),
+ Constraint "status_pkey" Primary Key ("id")
+);
+
+--
+-- TOC Entry ID 19 (OID 17341)
+--
+-- Name: creditors Type: TABLE Owner: postgres
+--
+
+CREATE TABLE "creditors" (
+ "id" integer DEFAULT nextval('creditors_id_seq'::text) NOT NULL,
+ "forename" character(40),
+ "surname" character(40),
+ "city" character(30),
+ Constraint "creditors_pkey" Primary Key ("id")
+);
+
+--
+-- TOC Entry ID 20 (OID 17344)
+--
+-- Name: prices Type: TABLE Owner: postgres
+--
+
+CREATE TABLE "prices" (
+ "id" integer NOT NULL,
+ "name" character(40),
+ "price" real,
+ Constraint "prices_pkey" Primary Key ("id")
+);
+
+--
+-- TOC Entry ID 21 (OID 17347)
+--
+-- Name: invoiceitem Type: TABLE Owner: postgres
+--
+
+CREATE TABLE "invoiceitem" (
+ "id" integer DEFAULT nextval('invoice_id_seq'::text) NOT NULL,
+ "pricesid" integer,
+ "quantity" integer,
+ "paiddate" date,
+ Constraint "invoiceitem_pkey" Primary Key ("id")
+);
+
+--
+-- TOC Entry ID 2 (OID 17351)
+--
+-- Name: people_id_seq Type: SEQUENCE Owner: postgres
+--
+
+CREATE SEQUENCE "people_id_seq" start 1 increment 1 maxvalue 2147483647 minvalue 1 cache 1;
+
+--
+-- TOC Entry ID 4 (OID 17353)
+--
+-- Name: staff_id_seq Type: SEQUENCE Owner: postgres
+--
+
+CREATE SEQUENCE "staff_id_seq" start 1 increment 1 maxvalue 2147483647 minvalue 1 cache 1;
+
+--
+-- TOC Entry ID 6 (OID 17355)
+--
+-- Name: creditors_id_seq Type: SEQUENCE Owner: postgres
+--
+
+CREATE SEQUENCE "creditors_id_seq" start 1 increment 1 maxvalue 2147483647 minvalue 1 cache 1;
+
+--
+-- TOC Entry ID 8 (OID 17357)
+--
+-- Name: invoice_id_seq Type: SEQUENCE Owner: postgres
+--
+
+CREATE SEQUENCE "invoice_id_seq" start 1 increment 1 maxvalue 2147483647 minvalue 1 cache 1;
+
+--
+-- Data for TOC Entry ID 28 (OID 17332)
+--
+-- Name: people Type: TABLE DATA Owner: postgres
+--
+
+
+COPY "people" FROM stdin;
+\.
+--
+-- Data for TOC Entry ID 29 (OID 17335)
+--
+-- Name: staff Type: TABLE DATA Owner: postgres
+--
+
+
+COPY "staff" FROM stdin;
+1 Hugo Hurtig $123,450.50 0
+2 Alfred E. Neumann $56,780.90 1
+3 Agate Schnell-Fertig $12,340.56 2
+6 Eugen Nutzlos -$7,833.56 3
+7 Harald Schmidt -$150,000.00 3
+4 Urmel auf dem Eis $7,778.00 2
+5 Emil Dotterschreck -$5,670.23 3
+\.
+--
+-- Data for TOC Entry ID 30 (OID 17338)
+--
+-- Name: status Type: TABLE DATA Owner: postgres
+--
+
+
+COPY "status" FROM stdin;
+0 Chief
+1 Programmer
+2 Secretary
+3 Driver
+\.
+--
+-- Data for TOC Entry ID 31 (OID 17341)
+--
+-- Name: creditors Type: TABLE DATA Owner: postgres
+--
+
+
+COPY "creditors" FROM stdin;
+\.
+--
+-- Data for TOC Entry ID 32 (OID 17344)
+--
+-- Name: prices Type: TABLE DATA Owner: postgres
+--
+
+
+COPY "prices" FROM stdin;
+0 Waschbecken 150.25
+1 Wellensittich 27.95
+2 Roter Papagei 850
+3 Spam & Eggs -7.5
+4 Renault Espace 9000
+5 Tux, der Pinguin 65.35
+6 Makroskop 985000
+7 Regenbaum 1235.65
+8 Bluterguß 23.95
+9 Weltmeisterschaft 2.95
+10 Premiere Dekoder -185.75
+\.
+--
+-- Data for TOC Entry ID 33 (OID 17347)
+--
+-- Name: invoiceitem Type: TABLE DATA Owner: postgres
+--
+
+
+COPY "invoiceitem" FROM stdin;
+\.
+--
+-- TOC Entry ID 3 (OID 17351)
+--
+-- Name: people_id_seq Type: SEQUENCE SET Owner: postgres
+--
+
+SELECT setval ('"people_id_seq"', 1, false);
+
+--
+-- TOC Entry ID 5 (OID 17353)
+--
+-- Name: staff_id_seq Type: SEQUENCE SET Owner: postgres
+--
+
+SELECT setval ('"staff_id_seq"', 8, true);
+
+--
+-- TOC Entry ID 7 (OID 17355)
+--
+-- Name: creditors_id_seq Type: SEQUENCE SET Owner: postgres
+--
+
+SELECT setval ('"creditors_id_seq"', 1, false);
+
+--
+-- TOC Entry ID 9 (OID 17357)
+--
+-- Name: invoice_id_seq Type: SEQUENCE SET Owner: postgres
+--
+
+SELECT setval ('"invoice_id_seq"', 1, false);
+