qsqldatabase.sip 3.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. // qsqldatabase.sip generated by MetaSIP
  2. //
  3. // This file is part of the QtSql Python extension module.
  4. //
  5. // Copyright (c) 2026 Riverbank Computing Limited <info@riverbankcomputing.com>
  6. //
  7. // This file is part of PyQt6.
  8. //
  9. // This file may be used under the terms of the GNU General Public License
  10. // version 3.0 as published by the Free Software Foundation and appearing in
  11. // the file LICENSE included in the packaging of this file. Please review the
  12. // following information to ensure the GNU General Public License version 3.0
  13. // requirements will be met: http://www.gnu.org/copyleft/gpl.html.
  14. //
  15. // If you do not wish to use this file under the terms of the GPL version 3.0
  16. // then you may purchase a commercial license. For more information contact
  17. // info@riverbankcomputing.com.
  18. //
  19. // This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
  20. // WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  21. class QSqlDriverCreatorBase /Supertype=PyQt6.sip.wrapper/
  22. {
  23. %TypeHeaderCode
  24. #include <qsqldatabase.h>
  25. %End
  26. public:
  27. virtual ~QSqlDriverCreatorBase();
  28. virtual QSqlDriver *createObject() const = 0 /Factory/;
  29. };
  30. class QSqlDatabase
  31. {
  32. %TypeHeaderCode
  33. #include <qsqldatabase.h>
  34. %End
  35. public:
  36. QSqlDatabase();
  37. QSqlDatabase(const QSqlDatabase &other);
  38. ~QSqlDatabase();
  39. bool open() /ReleaseGIL/;
  40. bool open(const QString &user, const QString &password) /ReleaseGIL/;
  41. void close();
  42. bool isOpen() const;
  43. bool isOpenError() const;
  44. QStringList tables(QSql::TableType type = QSql::Tables) const;
  45. QSqlIndex primaryIndex(const QString &tablename) const;
  46. QSqlRecord record(const QString &tablename) const;
  47. QSqlQuery exec(const QString &query = QString()) const /ReleaseGIL/;
  48. QSqlError lastError() const;
  49. bool isValid() const;
  50. bool transaction() /ReleaseGIL/;
  51. bool commit() /ReleaseGIL/;
  52. bool rollback() /ReleaseGIL/;
  53. void setDatabaseName(const QString &name);
  54. void setUserName(const QString &name);
  55. void setPassword(const QString &password);
  56. void setHostName(const QString &host);
  57. void setPort(int p);
  58. void setConnectOptions(const QString &options = QString());
  59. QString databaseName() const;
  60. QString userName() const;
  61. QString password() const;
  62. QString hostName() const;
  63. QString driverName() const;
  64. int port() const;
  65. QString connectOptions() const;
  66. QString connectionName() const;
  67. QSqlDriver *driver() const;
  68. static QSqlDatabase addDatabase(const QString &type, const QString &connectionName = QLatin1String(QSqlDatabase::defaultConnection));
  69. static QSqlDatabase addDatabase(QSqlDriver *driver, const QString &connectionName = QLatin1String(QSqlDatabase::defaultConnection));
  70. static QSqlDatabase cloneDatabase(const QSqlDatabase &other, const QString &connectionName);
  71. static QSqlDatabase cloneDatabase(const QString &other, const QString &connectionName);
  72. static QSqlDatabase database(const QString &connectionName = QLatin1String(QSqlDatabase::defaultConnection), bool open = true);
  73. static void removeDatabase(const QString &connectionName);
  74. static bool contains(const QString &connectionName = QLatin1String(QSqlDatabase::defaultConnection));
  75. static QStringList drivers();
  76. static QStringList connectionNames();
  77. static void registerSqlDriver(const QString &name, QSqlDriverCreatorBase *creator /Transfer/);
  78. static bool isDriverAvailable(const QString &name);
  79. protected:
  80. explicit QSqlDatabase(const QString &type);
  81. explicit QSqlDatabase(QSqlDriver *driver);
  82. public:
  83. void setNumericalPrecisionPolicy(QSql::NumericalPrecisionPolicy precisionPolicy);
  84. QSql::NumericalPrecisionPolicy numericalPrecisionPolicy() const;
  85. %If (Qt_6_8_0 -)
  86. bool moveToThread(QThread *targetThread);
  87. %End
  88. %If (Qt_6_8_0 -)
  89. QThread *thread() const;
  90. %End
  91. };