使用Python第三方库PyGreSQL连接集群 使用约束 由于PyGreSQL是基于PostgreSQL的客户端接口,它的功能DWS并不能完全支持。具体支持情况请见下表。 说明 以下接口支持情况是基于Python 3.8.5及PyGreSQL 5.2.4版本。 DWS对PyGreSQL主要接口支持情况 PyGreSQL 支持 备注 Module functions and constants connect–Open a PostgreSQL connection Y Module functions and constants getpqlibversion–get the version of libpq Y Module functions and constants get/setdefhost–default server host [DV] Y Module functions and constants get/setdefport–default server port [DV] Y Module functions and constants get/setdefopt–default connection options [DV] Y Module functions and constants get/setdefbase–default database name [DV] Y Module functions and constants get/setdefuser–default database user [DV] Y Module functions and constants get/setdefpasswd–default database password [DV] Y Module functions and constants escapestring–escape a string for use within SQL Y Module functions and constants escapebytea–escape binary data for use within SQL Y Module functions and constants unescapebytea–unescape data that has been retrieved as text Y Module functions and constants get/setnamedresult–conversion to named tuples Y Module functions and constants get/setdecimal–decimal type to be used for numeric values Y Module functions and constants get/setdecimalpoint–decimal mark used for monetary values Y Module functions and constants get/setbool–whether boolean values are returned as bool objects Y Module functions and constants get/setarray–whether arrays are returned as list objects Y Module functions and constants get/setbyteaescaped–whether bytea data is returned escaped Y Module functions and constants get/setjsondecode–decoding JSON format Y Module functions and constants get/setcasthook–fallback typecast function Y Module functions and constants get/setdatestyle–assume a fixed date style Y Module functions and constants get/settypecast–custom typecasting Y Module functions and constants castarray/record–fast parsers for arrays and records Y Module functions and constants Type helpers Y Module functions and constants Module constants Y Connection–The connection object query–execute a SQL command string Y Connection–The connection object sendquery executes a SQL command string asynchronously Y Connection–The connection object queryprepared–execute a prepared statement Y Connection–The connection object prepare–create a prepared statement Y Connection–The connection object describeprepared–describe a prepared statement Y Connection–The connection object reset–reset the connection Y Connection–The connection object poll completes an asynchronous connection Y Connection–The connection object cancel–abandon processing of current SQL command Y Connection–The connection object close–close the database connection Y Connection–The connection object transaction–get the current transaction state Y Connection–The connection object parameter–get a current server parameter setting Y Connection–The connection object dateformat–get the currently used date format Y Connection–The connection object fileno–get the socket used to connect to the database Y Connection–The connection object setnonblocking set the nonblocking status of the connection Y Connection–The connection object isnonblocking report the blocking status of the connection Y Connection–The connection object getnotify–get the last notify from the server N 数据库不支持listen/notify Connection–The connection object inserttable–insert a list into a table Y copy命令中如果有n,请使用双引号引用此字段 Connection–The connection object get/setnoticereceiver–custom notice receiver Y Connection–The connection object putline–write a line to the server socket [DA] Y Connection–The connection object getline–get a line from server socket [DA] Y Connection–The connection object endcopy–synchronize client and server [DA] Y Connection–The connection object locreate–create a large object in the database [LO] N 大对象相关操作 Connection–The connection object getlo–build a large object from given oid [LO] N 大对象相关操作 Connection–The connection object loimport–import a file to a large object [LO] N 大对象相关操作 Connection–The connection object Object attributes Y The DB wrapper class Initialization Y The DB wrapper class pkey–return the primary key of a table Y The DB wrapper class getdatabases–get list of databases in the system Y The DB wrapper class getrelations–get list of relations in connected database Y The DB wrapper class gettables–get list of tables in connected database Y The DB wrapper class getattnames–get the attribute names of a table Y The DB wrapper class hastableprivilege–check table privilege Y The DB wrapper class get/setparameter–get or set runtime parameters Y The DB wrapper class begin/commit/rollback/savepoint/release–transaction handling Y The DB wrapper class get–get a row from a database table or view Y The DB wrapper class insert–insert a row into a database table Y The DB wrapper class update–update a row in a database table Y The DB wrapper class upsert–insert a row with conflict resolution Y The DB wrapper class query–execute a SQL command string Y The DB wrapper class queryformatted–execute a formatted SQL command string Y The DB wrapper class queryprepared–execute a prepared statement Y The DB wrapper class prepare–create a prepared statement Y The DB wrapper class describeprepared–describe a prepared statement Y The DB wrapper class deleteprepared–delete a prepared statement Y The DB wrapper class clear–clear row values in memory Y The DB wrapper class delete–delete a row from a database table Y 元组必须有唯一键或者主键 The DB wrapper class truncate–quickly empty database tables Y The DB wrapper class getaslist/dict–read a table as a list or dictionary Y The DB wrapper class escapeliteral/identifier/string/bytea–escape for SQL Y The DB wrapper class unescapebytea– unescape data retrieved from the database Y The DB wrapper class encode/decodejson–encode and decode JSON data Y The DB wrapper class useregtypes–determine use of regular type names Y The DB wrapper class notificationhandler–create a notification handler N 数据库不支持listen/notify The DB wrapper class Attributes of the DB wrapper class Y Query methods getresult–get query values as list of tuples Y Query methods dictresult/dictiter–get query values as dictionaries Y Query methods namedresult/namediter–get query values as named tuples Y Query methods scalarresult/scalariter–get query values as scalars Y Query methods one/onedict/onenamed/onescalar–get one result of a query Y Query methods single/singledict/singlenamed/singlescalar–get single result of a query Y Query methods listfields–list fields names of previous query result Y Query methods fieldname, fieldnum–field name/number conversion Y Query methods fieldinfo–detailed info about query result fields Y Query methods ntuples–return number of tuples in query object Y Query methods memsize–return number of bytes allocated by query result Y LargeObject–Large Objects open–open a large object N 大对象相关操作 LargeObject–Large Objects close–close a large object N 大对象相关操作 LargeObject–Large Objects read, write, tell, seek, unlink–filelike large object handling N 大对象相关操作 LargeObject–Large Objects size–get the large object size N 大对象相关操作 LargeObject–Large Objects export–save a large object to a file N 大对象相关操作 LargeObject–Large Objects Object attributes N 大对象相关操作 The Notification Handler Instantiating the notification handler N 数据库不支持listen/notify The Notification Handler Invoking the notification handler N 数据库不支持listen/notify The Notification Handler Sending notifications N 数据库不支持listen/notify The Notification Handler Auxiliary methods N 数据库不支持listen/notify pgdb Module functions and constants connect–Open a PostgreSQL connection Y Module functions and constants get/set/resettypecast–Control the global typecast functions Y Module functions and constants Module constants Y Module functions and constants Errors raised by this module Y Connection–The connection object close–close the connection Y Connection–The connection object commit–commit the connection Y Connection–The connection object rollback–roll back the connection Y Connection–The connection object cursor–return a new cursor object Y Connection–The connection object Attributes that are not part of the standard Y Cursor–The cursor object description–details regarding the result columns Y Cursor–The cursor object rowcount–number of rows of the result Y Cursor–The cursor object close–close the cursor Y Cursor–The cursor object execute–execute a database operation Y Cursor–The cursor object executemany–execute many similar database operations Y Cursor–The cursor object callproc–Call a stored procedure Y Cursor–The cursor object fetchone–fetch next row of the query result Y Cursor–The cursor object fetchmany–fetch next set of rows of the query result Y Cursor–The cursor object fetchall–fetch all rows of the query result Y Cursor–The cursor object arraysize the number of rows to fetch at a time Y Cursor–The cursor object Methods and attributes that are not part of the standard Y Type–Type objects and constructors Type constructors Y Type–Type objects and constructors Type objects Y
来自: