From 90825e2392b2d70e43c7a25b8a3752299a933894 Mon Sep 17 00:00:00 2001 From: toma Date: Wed, 25 Nov 2009 17:56:58 +0000 Subject: Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features. BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdebindings@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- python/pyqt/examples3/SQL/README | 76 +++++++ python/pyqt/examples3/SQL/connect.ui | 238 +++++++++++++++++++++ python/pyqt/examples3/SQL/connect.ui.h | 21 ++ python/pyqt/examples3/SQL/dbconnect.py | 82 ++++++++ python/pyqt/examples3/SQL/dbpar.py | 22 ++ python/pyqt/examples3/SQL/form1.ui | 77 +++++++ python/pyqt/examples3/SQL/form2.ui | 327 +++++++++++++++++++++++++++++ python/pyqt/examples3/SQL/frmconnect.py | 120 +++++++++++ python/pyqt/examples3/SQL/frmconnect.ui | 245 +++++++++++++++++++++ python/pyqt/examples3/SQL/runform1.py | 21 ++ python/pyqt/examples3/SQL/runform2.py | 21 ++ python/pyqt/examples3/SQL/runsqlex.py | 151 +++++++++++++ python/pyqt/examples3/SQL/sqlcustom1.py | 94 +++++++++ python/pyqt/examples3/SQL/sqlex.ui | 303 ++++++++++++++++++++++++++ python/pyqt/examples3/SQL/sqlex.ui.h | 35 +++ python/pyqt/examples3/SQL/sqlsubclass5.py | 151 +++++++++++++ python/pyqt/examples3/SQL/sqltable4.py | 118 +++++++++++ python/pyqt/examples3/SQL/testdb_mysql.sql | 57 +++++ python/pyqt/examples3/SQL/testdb_pg.sql | 232 ++++++++++++++++++++ 19 files changed, 2391 insertions(+) create mode 100644 python/pyqt/examples3/SQL/README create mode 100644 python/pyqt/examples3/SQL/connect.ui create mode 100644 python/pyqt/examples3/SQL/connect.ui.h create mode 100755 python/pyqt/examples3/SQL/dbconnect.py create mode 100644 python/pyqt/examples3/SQL/dbpar.py create mode 100644 python/pyqt/examples3/SQL/form1.ui create mode 100644 python/pyqt/examples3/SQL/form2.ui create mode 100644 python/pyqt/examples3/SQL/frmconnect.py create mode 100644 python/pyqt/examples3/SQL/frmconnect.ui create mode 100755 python/pyqt/examples3/SQL/runform1.py create mode 100755 python/pyqt/examples3/SQL/runform2.py create mode 100755 python/pyqt/examples3/SQL/runsqlex.py create mode 100755 python/pyqt/examples3/SQL/sqlcustom1.py create mode 100644 python/pyqt/examples3/SQL/sqlex.ui create mode 100644 python/pyqt/examples3/SQL/sqlex.ui.h create mode 100755 python/pyqt/examples3/SQL/sqlsubclass5.py create mode 100755 python/pyqt/examples3/SQL/sqltable4.py create mode 100644 python/pyqt/examples3/SQL/testdb_mysql.sql create mode 100644 python/pyqt/examples3/SQL/testdb_pg.sql (limited to 'python/pyqt/examples3/SQL') diff --git a/python/pyqt/examples3/SQL/README b/python/pyqt/examples3/SQL/README new file mode 100644 index 00000000..9dfc5d41 --- /dev/null +++ b/python/pyqt/examples3/SQL/README @@ -0,0 +1,76 @@ +This directory contains some translated sql examples from Qt 3.x. + +runform1.py, form1.ui: + + A simple designer generated QDataTable. Run "pyuic form1.ui -o form1.py". + +runform2.py, form2.ui: + + A simple designer generated QDataBrowser. Run "pyuic form2.ui -o form2.py". + +sqlcustom1.py: + + QSqlForm based form with a simple custom editor forcing all input to + be uppercase + +sqltable4.py: + + Custom QDataTable with reimplemented paintField method, combined with + a QComboBox based custom field editor (StatusPicker), gathering its + items from a different table (status) and a calculated column (monsalary). + Note, that QSqlEditorFactory based field editors are somewhat restricted, + because Qt's Q_PROPERTY feature isn't supported, yet. I've circumvented + this limitation by choosing the status table ids corresponding to the + index in the QComboBox. + +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 QSqlCursor + driven by QSqlQuery 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 Qt 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 Qt 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 . + +Good luck + +Hans-Peter Jansen diff --git a/python/pyqt/examples3/SQL/connect.ui b/python/pyqt/examples3/SQL/connect.ui new file mode 100644 index 00000000..cc419203 --- /dev/null +++ b/python/pyqt/examples3/SQL/connect.ui @@ -0,0 +1,238 @@ + +ConnectDialog + + + ConnectDialog + + + + 0 + 0 + 303 + 251 + + + + Connect... + + + + unnamed + + + 11 + + + 6 + + + + GroupBox3 + + + Connection settings + + + + unnamed + + + 11 + + + 6 + + + + editDatabase + + + + + TextLabel3 + + + Database Name: + + + comboDatabase + + + + + editPassword + + + Password + + + + + TextLabel4 + + + &Username: + + + editUsername + + + + + TextLabel4_2 + + + &Password: + + + editPassword + + + + + comboDriver + + + + + editUsername + + + + + editHostname + + + + + TextLabel5 + + + &Hostname: + + + editHostname + + + + + TextLabel5_2 + + + P&ort: + + + portSpinBox + + + + + portSpinBox + + + Default + + + 65535 + + + -1 + + + -1 + + + + + TextLabel2 + + + D&river + + + comboDriver + + + + + + + Layout25 + + + + unnamed + + + 0 + + + 6 + + + + Spacer1 + + + Horizontal + + + Expanding + + + + + PushButton1 + + + &OK + + + true + + + + + PushButton2 + + + &Cancel + + + + + + + + + PushButton1 + clicked() + ConnectDialog + accept() + + + PushButton2 + clicked() + ConnectDialog + reject() + + + + comboDriver + editDatabase + editUsername + editPassword + editHostname + portSpinBox + PushButton1 + PushButton2 + + + connect.ui.h + + + init() + destroy() + + + diff --git a/python/pyqt/examples3/SQL/connect.ui.h b/python/pyqt/examples3/SQL/connect.ui.h new file mode 100644 index 00000000..cbeeabdc --- /dev/null +++ b/python/pyqt/examples3/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 Qt 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 qtsql import QSqlDatabase +#qDebug("ConnectDialog init") +self.comboDriver.clear() +self.comboDriver.insertStringList(QSqlDatabase.drivers()) +} + +void ConnectDialog::destroy() +{ + +} diff --git a/python/pyqt/examples3/SQL/dbconnect.py b/python/pyqt/examples3/SQL/dbconnect.py new file mode 100755 index 00000000..fdae7de1 --- /dev/null +++ b/python/pyqt/examples3/SQL/dbconnect.py @@ -0,0 +1,82 @@ +#!/usr/bin/env python + +import sys +from qt import * +from qtsql import * + +from frmconnect import frmConnect +from dbpar import * + +TRUE = 1 +FALSE = 0 + +def createConnection(): + driver = DB_DRIVER + # all qt examples use QSqlDatabase::addDatabase, but + # this never returns NULL in my experience + drivers = map(str, QSqlDatabase.drivers()) + if driver in drivers: + dlg = dbConnect(driver) + #TODO: make connection parameters accessible + return dlg.exec_loop() + else: + QMessageBox.warning(None, "Database Error", + "<%s> database driver not found!\n\n" + "Please make sure, that this database adaptor\n" + "is available in your Qt installation.\n" % + (driver), QMessageBox.Abort | QMessageBox.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) + map(self.cmbServer.insertItem, self.hostnames) + 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 = QSqlDatabase.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: + QMessageBox.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): + QMessageBox.information(self, "About Connecting", + "Here you specify userid, password, host and database\n" + "for the PyQt sql examples. If you encounter any problems,\n" + "please read the README file in this folder before posting.\n\n" + "Thanks,\nHans-Peter Jansen \n") + + +if __name__ == "__main__": + app = QApplication(sys.argv) + if createConnection(): + print "ok" + else: + print "cancel" diff --git a/python/pyqt/examples3/SQL/dbpar.py b/python/pyqt/examples3/SQL/dbpar.py new file mode 100644 index 00000000..90e92704 --- /dev/null +++ b/python/pyqt/examples3/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 = "QPSQL7" +DB_DRIVER = "QMYSQL3" +# 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/python/pyqt/examples3/SQL/form1.ui b/python/pyqt/examples3/SQL/form1.ui new file mode 100644 index 00000000..38b3cb27 --- /dev/null +++ b/python/pyqt/examples3/SQL/form1.ui @@ -0,0 +1,77 @@ + +Form1 + + + Form1 + + + + 0 + 0 + 600 + 370 + + + + Form1 + + + + + Forename + + + forename + + + + + Surname + + + surname + + + + + Salary + + + salary + + + + + Statusid + + + statusid + + + + DataTable2 + + + + 0 + 0 + 600 + 370 + + + + true + + + true + + + + (default) + staff + + + + + + diff --git a/python/pyqt/examples3/SQL/form2.ui b/python/pyqt/examples3/SQL/form2.ui new file mode 100644 index 00000000..ffe2beb5 --- /dev/null +++ b/python/pyqt/examples3/SQL/form2.ui @@ -0,0 +1,327 @@ + +Form2 + + + Form2 + + + + 0 + 0 + 367 + 152 + + + + Form2 + + + + DataBrowser1 + + + + 0 + 0 + 366 + 150 + + + + + surname ASC + forename ASC + + + + + (default) + staff + + + + + unnamed + + + 11 + + + 6 + + + + Layout2 + + + + unnamed + + + 0 + + + 6 + + + + labelSurname + + + Surname + + + + + QSpinBoxStatusid + + + 2147483647 + + + + (default) + staff + statusid + + + + + + QLineEditSurname + + + + (default) + staff + surname + + + + + + labelStatusid + + + Statusid + + + + + labelForename + + + Forename + + + + + QLineEditSalary + + + AlignRight + + + + (default) + staff + salary + + + + + + labelSalary + + + Salary + + + + + QLineEditForename + + + + (default) + staff + forename + + + + + + + + Layout3 + + + + unnamed + + + 0 + + + 6 + + + + PushButtonFirst + + + |< &First + + + + + PushButtonPrev + + + << &Prev + + + + + PushButtonNext + + + &Next >> + + + + + PushButtonLast + + + &Last >| + + + + + + + Layout4 + + + + unnamed + + + 0 + + + 6 + + + + PushButtonInsert + + + &Insert + + + + + PushButtonUpdate + + + &Update + + + + + PushButtonDelete + + + &Delete + + + + + + + + + + PushButtonFirst + clicked() + DataBrowser1 + first() + + + DataBrowser1 + firstRecordAvailable( bool ) + PushButtonFirst + setEnabled(bool) + + + PushButtonPrev + clicked() + DataBrowser1 + prev() + + + DataBrowser1 + prevRecordAvailable( bool ) + PushButtonPrev + setEnabled(bool) + + + PushButtonNext + clicked() + DataBrowser1 + next() + + + DataBrowser1 + nextRecordAvailable( bool ) + PushButtonNext + setEnabled(bool) + + + PushButtonLast + clicked() + DataBrowser1 + last() + + + DataBrowser1 + lastRecordAvailable( bool ) + PushButtonLast + setEnabled(bool) + + + PushButtonInsert + clicked() + DataBrowser1 + insert() + + + PushButtonUpdate + clicked() + DataBrowser1 + update() + + + PushButtonDelete + clicked() + DataBrowser1 + del() + + + + QLineEditForename + QLineEditSurname + QLineEditSalary + QSpinBoxStatusid + PushButtonFirst + PushButtonPrev + PushButtonNext + PushButtonLast + PushButtonInsert + PushButtonUpdate + PushButtonDelete + + + diff --git a/python/pyqt/examples3/SQL/frmconnect.py b/python/pyqt/examples3/SQL/frmconnect.py new file mode 100644 index 00000000..23cd0674 --- /dev/null +++ b/python/pyqt/examples3/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 PyQt User Interface Compiler (pyuic) +# +# WARNING! All changes made in this file will be lost! + + +from qt import * + + +class frmConnect(QDialog): + def __init__(self,parent = None,name = None,modal = 0,fl = 0): + QDialog.__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 = QGridLayout(self,1,1,11,6,"frmConnectLayout") + + Layout7 = QVBoxLayout(None,0,6,"Layout7") + + self.buttonOK = QPushButton(self,"buttonOK") + self.buttonOK.setText(self.trUtf8("&OK")) + self.buttonOK.setAutoDefault(1) + self.buttonOK.setDefault(1) + QToolTip.add(self.buttonOK,self.trUtf8("Connect to Database")) + Layout7.addWidget(self.buttonOK) + + self.buttonCancel = QPushButton(self,"buttonCancel") + self.buttonCancel.setText(self.trUtf8("&Cancel")) + QToolTip.add(self.buttonCancel,self.trUtf8("Cancel Connecting")) + Layout7.addWidget(self.buttonCancel) + + self.buttonHelp = QPushButton(self,"buttonHelp") + self.buttonHelp.setText(self.trUtf8("&Help")) + QToolTip.add(self.buttonHelp,self.trUtf8("About Connecting")) + Layout7.addWidget(self.buttonHelp) + spacer = QSpacerItem(0,0,QSizePolicy.Minimum,QSizePolicy.Expanding) + Layout7.addItem(spacer) + + frmConnectLayout.addLayout(Layout7,0,1) + + self.grpConnection = QGroupBox(self,"grpConnection") + self.grpConnection.setTitle(self.trUtf8("")) + self.grpConnection.setColumnLayout(0,Qt.Vertical) + self.grpConnection.layout().setSpacing(6) + self.grpConnection.layout().setMargin(11) + grpConnectionLayout = QGridLayout(self.grpConnection.layout()) + grpConnectionLayout.setAlignment(Qt.AlignTop) + + self.txtName = QLineEdit(self.grpConnection,"txtName") + self.txtName.setMaxLength(16) + QToolTip.add(self.txtName,self.trUtf8("Database User ID")) + + grpConnectionLayout.addWidget(self.txtName,0,1) + + self.lblDatabase = QLabel(self.grpConnection,"lblDatabase") + self.lblDatabase.setText(self.trUtf8("&Database")) + + grpConnectionLayout.addWidget(self.lblDatabase,3,0) + + self.lblServer = QLabel(self.grpConnection,"lblServer") + self.lblServer.setText(self.trUtf8("&Server")) + + grpConnectionLayout.addWidget(self.lblServer,2,0) + + self.lblName = QLabel(self.grpConnection,"lblName") + self.lblName.setText(self.trUtf8("&Name")) + + grpConnectionLayout.addWidget(self.lblName,0,0) + + self.cmbDatabase = QComboBox(0,self.grpConnection,"cmbDatabase") + self.cmbDatabase.setEditable(1) + self.cmbDatabase.setAutoCompletion(1) + self.cmbDatabase.setDuplicatesEnabled(0) + QToolTip.add(self.cmbDatabase,self.trUtf8("Database Name")) + + grpConnectionLayout.addWidget(self.cmbDatabase,3,1) + + self.txtPasswd = QLineEdit(self.grpConnection,"txtPasswd") + self.txtPasswd.setMaxLength(16) + self.txtPasswd.setEchoMode(QLineEdit.Password) + QToolTip.add(self.txtPasswd,self.trUtf8("Database User Password")) + + grpConnectionLayout.addWidget(self.txtPasswd,1,1) + + self.lblPasswd = QLabel(self.grpConnection,"lblPasswd") + self.lblPasswd.setText(self.trUtf8("&Password")) + + grpConnectionLayout.addWidget(self.lblPasswd,1,0) + + self.cmbServer = QComboBox(0,self.grpConnection,"cmbServer") + self.cmbServer.setEditable(1) + self.cmbServer.setAutoCompletion(1) + self.cmbServer.setDuplicatesEnabled(0) + QToolTip.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/python/pyqt/examples3/SQL/frmconnect.ui b/python/pyqt/examples3/SQL/frmconnect.ui new file mode 100644 index 00000000..a6fc15cc --- /dev/null +++ b/python/pyqt/examples3/SQL/frmconnect.ui @@ -0,0 +1,245 @@ + +frmConnect + + + frmConnect + + + + 0 + 0 + 415 + 154 + + + + Connecting + + + true + + + + unnamed + + + 11 + + + 6 + + + + Layout7 + + + + unnamed + + + 0 + + + 6 + + + + buttonOK + + + &OK + + + true + + + true + + + Connect to Database + + + + + buttonCancel + + + &Cancel + + + Cancel Connecting + + + + + buttonHelp + + + &Help + + + About Connecting + + + + + spacer + + + Vertical + + + Expanding + + + + + + + grpConnection + + + + + + + unnamed + + + 11 + + + 6 + + + + txtName + + + 16 + + + Database User ID + + + + + lblDatabase + + + &Database + + + cmbDatabase + + + + + lblServer + + + &Server + + + cmbServer + + + + + lblName + + + &Name + + + txtName + + + + + cmbDatabase + + + true + + + true + + + false + + + Database Name + + + + + txtPasswd + + + 16 + + + Password + + + Database User Password + + + + + lblPasswd + + + &Password + + + txtPasswd + + + + + cmbServer + + + true + + + true + + + false + + + Database Server Address + + + + + + + + + buttonOK + clicked() + frmConnect + accept() + + + buttonCancel + clicked() + frmConnect + reject() + + + + txtName + txtPasswd + cmbServer + cmbDatabase + buttonOK + buttonCancel + buttonHelp + + + diff --git a/python/pyqt/examples3/SQL/runform1.py b/python/pyqt/examples3/SQL/runform1.py new file mode 100755 index 00000000..d5760ce1 --- /dev/null +++ b/python/pyqt/examples3/SQL/runform1.py @@ -0,0 +1,21 @@ +#!/usr/bin/env python + +import sys +from 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 = QApplication(sys.argv) + if createConnection(): + QObject.connect(a,SIGNAL("lastWindowClosed()"),a,SLOT("quit()")) + w = mainWindow() + a.setMainWidget(w) + w.show() + a.exec_loop() + diff --git a/python/pyqt/examples3/SQL/runform2.py b/python/pyqt/examples3/SQL/runform2.py new file mode 100755 index 00000000..ba0ca4a5 --- /dev/null +++ b/python/pyqt/examples3/SQL/runform2.py @@ -0,0 +1,21 @@ +#!/usr/bin/env python + +import sys +from 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 = QApplication(sys.argv) + if createConnection(): + QObject.connect(a,SIGNAL("lastWindowClosed()"),a,SLOT("quit()")) + w = mainWindow() + a.setMainWidget(w) + w.show() + a.exec_loop() + diff --git a/python/pyqt/examples3/SQL/runsqlex.py b/python/pyqt/examples3/SQL/runsqlex.py new file mode 100755 index 00000000..7f2afa71 --- /dev/null +++ b/python/pyqt/examples3/SQL/runsqlex.py @@ -0,0 +1,151 @@ +#!/usr/bin/env python + +import sys +from qt import * +from qtsql import * + +from sqlex import SqlEx +from connect import ConnectDialog + +from dbpar import * + +TRUE = 1 +FALSE = 0 + +def showError(err, parent): + errStr = QString("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") + QMessageBox.warning(parent, "Error", errStr) + +class CustomSqlCursor(QSqlCursor): + def __init__(self, query = None, autopopulate = TRUE, db = None): + QSqlCursor.__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(QSqlCursor.ReadOnly) + + def select(self, filter, sort = QSqlIndex()): + return self.execQuery(self.lastQuery()) + + def primaryIndex(self, prime = TRUE): + return QSqlIndex() + + 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() != QDialog.Accepted: + return + if self.dt.sqlCursor(): + self.dt.setSqlCursor() + + # close old connection (if any) + if QSqlDatabase.contains("SqlEx"): + oldDb = QSqlDatabase.database("SqlEx") + oldDb.close() + QSqlDatabase.removeDatabase("SqlEx") + + # open the new connection + db = QSqlDatabase.addDatabase(self.conDiag.comboDriver.currentText(), "SqlEx") + if not db: + QMessageBox.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 = QListViewItem(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 = QListViewItem(lvi, f.name(), QVariant.typeToName(f.type()), req) + lvi.insertItem(fi) + self.lv.insertItem(lvi) + + self.submitBtn.setEnabled(TRUE) + + def execQuery(self): + cursor = CustomSqlCursor(self.te.text(), TRUE, + QSqlDatabase.database("SqlEx", TRUE)) + if cursor.isSelect(): + self.dt.setSqlCursor(cursor, TRUE, TRUE) + self.dt.refresh() + txt = QString("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 = QSqlCursor(i.text(0), TRUE, QSqlDatabase.database("SqlEx", TRUE)) + self.dt.setSqlCursor(cursor, TRUE, TRUE) + self.dt.setSort(cursor.primaryIndex()) + self.dt.refresh(QDataTable.RefreshAll) + self.lbl.setText("Displaying table %s" % i.text(0)) + + +if __name__ == "__main__": + a = QApplication(sys.argv) + QObject.connect(a,SIGNAL("lastWindowClosed()"),a,SLOT("quit()")) + w = MainWindow() + a.setMainWidget(w) + w.show() + a.exec_loop() + diff --git a/python/pyqt/examples3/SQL/sqlcustom1.py b/python/pyqt/examples3/SQL/sqlcustom1.py new file mode 100755 index 00000000..46ca5801 --- /dev/null +++ b/python/pyqt/examples3/SQL/sqlcustom1.py @@ -0,0 +1,94 @@ +#!/usr/bin/env python + +#**************************************************************************** +#** $Id$ +#** +#** Copyright (C) 1992-1998 Troll Tech AS. All rights reserved. +#** +#** This file is part of an example program for PyQt. This example +#** program may be used, distributed and modified without limitation. +#** +#*****************************************************************************/ + +import sys +from qt import * +from qtsql import * + +from dbconnect import createConnection + +TRUE = 1 +FALSE = 0 + +class CustomEdit(QLineEdit): + def __init__(self, parent = None, name = None): + QLineEdit.__init__(self, parent, name) + QObject.connect(self, SIGNAL("textChanged(const QString &)"), + self.changed) + + def changed(self, line): + self.setUpperLine(line) + + def setUpperLine(self, line): + self.upperLineText = line.upper() + self.setText(self.upperLineText) + + +class FormDialog(QDialog): + def __init__(self): + QDialog.__init__(self) + forenameLabel = QLabel("Forename:", self) + forenameEdit = CustomEdit(self) + surnameLabel = QLabel("Surname:", self) + surnameEdit = CustomEdit(self) + salaryLabel = QLabel("Salary:", self) + salaryEdit = QLineEdit(self) + salaryEdit.setAlignment(Qt.AlignRight) + saveButton = QPushButton("&Save", self) + self.connect(saveButton, SIGNAL("clicked()"), self.save) + + grid = QGridLayout(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 = QSqlCursor("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 = QSqlPropertyMap() + self.propMap.insert(forenameEdit.className(), "upperLine") + + self.sqlForm = QSqlForm() + 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 = QApplication( sys.argv ) + + if createConnection(): + formDialog = FormDialog() + formDialog.show() + + app.setMainWidget(formDialog) + app.exec_loop() + + diff --git a/python/pyqt/examples3/SQL/sqlex.ui b/python/pyqt/examples3/SQL/sqlex.ui new file mode 100644 index 00000000..022fed93 --- /dev/null +++ b/python/pyqt/examples3/SQL/sqlex.ui @@ -0,0 +1,303 @@ + +SqlEx + + + SqlEx + + + + 0 + 0 + 669 + 438 + + + + SQL Browser + + + + unnamed + + + 11 + + + 6 + + + + Layout23 + + + + unnamed + + + 0 + + + 6 + + + + lbl + + + Press "Connect" to open a database + + + + + conBtn + + + + 0 + 0 + 0 + 0 + + + + + 80 + 0 + + + + &Connect... + + + + + + + vsplit + + + Vertical + + + + hsplit + + + Horizontal + + + + + Tables + + + true + + + true + + + + + Type + + + true + + + true + + + + + Required + + + true + + + true + + + + lv + + + 0 + + + true + + + true + + + LastColumn + + + + + dt + + + false + + + + + + gb + + + SQL Query + + + + unnamed + + + 11 + + + 6 + + + + Layout22 + + + + unnamed + + + 0 + + + 6 + + + + te + + + + + Layout21 + + + + unnamed + + + 0 + + + 6 + + + + Spacer3 + + + Horizontal + + + Expanding + + + + + submitBtn + + + + 5 + 0 + 0 + 0 + + + + + 80 + 0 + + + + &Submit + + + + + clearBtn + + + + 5 + 0 + 0 + 0 + + + + + 80 + 0 + + + + C&lear + + + + + + + + + + + + + + clearBtn + clicked() + te + clear() + + + conBtn + clicked() + SqlEx + dbConnect() + + + lv + returnPressed(QListViewItem*) + SqlEx + showTable(QListViewItem*) + + + lv + doubleClicked(QListViewItem*) + SqlEx + showTable(QListViewItem*) + + + submitBtn + clicked() + SqlEx + execQuery() + + + + sqlex.ui.h + + + init() + dbConnect() + showTable( QListViewItem * ) + execQuery() + + + diff --git a/python/pyqt/examples3/SQL/sqlex.ui.h b/python/pyqt/examples3/SQL/sqlex.ui.h new file mode 100644 index 00000000..1acdc5d4 --- /dev/null +++ b/python/pyqt/examples3/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 Qt 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, QSplitter.KeepSize) +self.vsplit.setResizeMode(self.gb, QSplitter.KeepSize) +self.submitBtn.setEnabled(0) +} + + +void SqlEx::dbConnect() +{ + +} + + +void SqlEx::showTable( QListViewItem * ) +{ + +} + + + +void SqlEx::execQuery() +{ + +} diff --git a/python/pyqt/examples3/SQL/sqlsubclass5.py b/python/pyqt/examples3/SQL/sqlsubclass5.py new file mode 100755 index 00000000..a130e78a --- /dev/null +++ b/python/pyqt/examples3/SQL/sqlsubclass5.py @@ -0,0 +1,151 @@ +#!/usr/bin/env python + +#**************************************************************************** +#** $Id$ +#** +#** Copyright (C) 1992-1998 Troll Tech AS. All rights reserved. +#** +#** This file is part of an example program for PyQt. This example +#** program may be used, distributed and modified without limitation. +#** +#*****************************************************************************/ + +import sys +from qt import * +from qtsql import * + +from dbconnect import createConnection + +TRUE = 1 +FALSE = 0 + +class CustomTable(QDataTable): + def __init__(self, cursor, autoPopulate = FALSE, parent = None, name = None): + QDataTable.__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 = QSqlQuery("SELECT name FROM prices WHERE id=%s" % + field.value().toString()) + value = "" + if query.next(): + 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, + Qt.AlignRight|Qt.AlignVCenter, field.value().toString()) + elif fn in ("price", "cost"): + v = field.value().toDouble() + if v < 0: + p.setPen(QColor("red")) + value = QString(u"%.2f \u20ac" % v) + p.drawText(2, 2, cr.width()-6, cr.height()-4, + Qt.AlignRight|Qt.AlignVCenter, value) + elif fn == "paiddate": + if field.value().toDate().isNull(): + v = QString("not yet") + p.setPen(QColor("red")) + else: + v = field.value().toDate().toString(Qt.LocalDate) + p.drawText(2, 2, cr.width()-4, cr.height()-4, + Qt.AlignHCenter|Qt.AlignVCenter, v) + else: + QDataTable.paintField(self, p, field, cr, b) + + +class InvoiceItemCursor(QSqlCursor): + def __init__(self): + QSqlCursor.__init__(self, "invoiceitem") + + productPrice = QSqlFieldInfo("price", QVariant.Double) + self.append(productPrice) + self.setCalculated(productPrice.name(), TRUE) + + productCost = QSqlFieldInfo("cost", QVariant.Double) + self.append(productCost) + self.setCalculated(productCost.name(), TRUE) + + def calculateField(self, name): + fn = str(name) + if fn == "productname": + query = QSqlQuery("SELECT name FROM prices WHERE id=%d;" % + (self.field("pricesid").value().toInt())) + if query.next(): + return query.value(0) + elif fn == "price": + query = QSqlQuery("SELECT price FROM prices WHERE id=%d;" % + (self.field("pricesid").value().toInt())) + if query.next(): + return query.value(0) + elif fn == "cost": + query = QSqlQuery("SELECT price FROM prices WHERE id=%d;" % + (self.field("pricesid").value().toInt())) + if query.next(): + return QVariant(query.value(0).toDouble() * + self.value("quantity").toDouble()) + return QVariant(QString.null) + + def primeInsert(self): + buffer = self.editBuffer() + buffer.setValue("id", QVariant(0)) + buffer.setValue("paiddate", QVariant(QDate.currentDate())) + buffer.setValue("quantity", QVariant(1)) + return buffer + + +class ProductPicker(QComboBox): + def __init__(self, parent = None, name = None): + QComboBox.__init__(self, parent, name) + cur = QSqlCursor("prices") + cur.select(cur.index("id")) + while cur.next(): + self.insertItem(cur.value("name").toString(), cur.value("id").toInt()) + + +class CustomSqlEditorFactory(QSqlEditorFactory): + def __init__(self): + QSqlEditorFactory.__init__(self) + + def createEditor(self, parent, field): + try: + if str(field.name()) == "pricesid": + return ProductPicker(parent) + except AttributeError: + pass + return QSqlEditorFactory.createEditor(self, parent, field) + +class Table(CustomTable): + def __init__(self): + self.invoiceItemCursor = InvoiceItemCursor() + QDataTable.__init__(self, self.invoiceItemCursor) + self.propMap = QSqlPropertyMap() + 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 = QApplication(sys.argv) + if createConnection(): + t = Table() + app.setMainWidget(t) + t.show() + app.exec_loop() + + diff --git a/python/pyqt/examples3/SQL/sqltable4.py b/python/pyqt/examples3/SQL/sqltable4.py new file mode 100755 index 00000000..4fa6ed06 --- /dev/null +++ b/python/pyqt/examples3/SQL/sqltable4.py @@ -0,0 +1,118 @@ +#!/usr/bin/env python + +#**************************************************************************** +#** $Id$ +#** +#** Copyright (C) 1992-1998 Troll Tech AS. All rights reserved. +#** +#** This file is part of an example program for PyQt. This example +#** program may be used, distributed and modified without limitation. +#** +#*****************************************************************************/ + +import sys +from qt import * +from qtsql import * + +from dbconnect import createConnection + +TRUE = 1 +FALSE = 0 + +class CustomTable(QDataTable): + def __init__(self, cursor, autoPopulate = FALSE, parent = None, name = None): + QDataTable.__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(QColor("red")) + value = QString(u"%.2f \u20ac" % v) + #print unicode(value).encode("iso-8859-15") + p.drawText(2, 2, cr.width()-6, cr.height()-4, + Qt.AlignRight|Qt.AlignVCenter, value) + elif fn == "statusid": + query = QSqlQuery("SELECT name FROM status WHERE id=%s" % + field.value().toString()) + value = "" + if query.next(): + value = query.value(0).toString() + p.drawText(2, 2, cr.width()-4, cr.height()-4, + self.fieldAlignment(field), value) + else: + QDataTable.paintField(self, p, field, cr, b) + + +class StatusPicker(QComboBox): + def __init__(self, parent = None, name = None): + QComboBox.__init__(self, parent, name) + cur = QSqlCursor("status") + cur.select(cur.index("id")) + while cur.next(): + self.insertItem(cur.value("name").toString(), cur.value("id").toInt()) + + +class CustomSqlEditorFactory(QSqlEditorFactory): + def __init__(self): + QSqlEditorFactory.__init__(self) + + def createEditor(self, parent, field): + try: + if str(field.name()) == "statusid": + return StatusPicker(parent) + except AttributeError: + pass + return QSqlEditorFactory.createEditor(self, parent, field) + + +class StaffCursor(QSqlCursor): + def __init__(self): + QSqlCursor.__init__(self, "staff") + monSalary = QSqlFieldInfo("monsalary", QVariant.Double) + self.append(monSalary) + self.setCalculated(monSalary.name(), TRUE) + + def calculateField(self, name): + if str(name) == "monsalary": + return QVariant(self.value("salary").toDouble() / 12) + return QVariant(QString.null) + + +class Table(CustomTable): + def __init__(self): + #self.staffCursor = QSqlCursor("staff") + self.staffCursor = StaffCursor() + QDataTable.__init__(self, self.staffCursor) + self.propMap = QSqlPropertyMap() + 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 = QStringList("surname") + self.order.append("forename") + self.setSort(self.order) + self.refresh() + + +if __name__=='__main__': + app = QApplication(sys.argv) + #app.setFont(QFont("Verdana", 11)) + + if createConnection(): + t = Table() + app.setMainWidget(t) + t.resize(600, 250) + t.show() + app.exec_loop() + + diff --git a/python/pyqt/examples3/SQL/testdb_mysql.sql b/python/pyqt/examples3/SQL/testdb_mysql.sql new file mode 100644 index 00000000..144d4c90 --- /dev/null +++ b/python/pyqt/examples3/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/python/pyqt/examples3/SQL/testdb_pg.sql b/python/pyqt/examples3/SQL/testdb_pg.sql new file mode 100644 index 00000000..73a42703 --- /dev/null +++ b/python/pyqt/examples3/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); + -- cgit v1.2.3