Appearance
PostgreSqlConnection Class
Definition
Connection to a PostgreSql Database
- Namespace:
JASE.Database.Connections - Assembly:
JASE.Database.dll
Properties
| Name | Description |
|---|---|
DatabaseType | String representing the type of database |
IsCiTextAvailable | Returns if the CITEXT extension is detected as installed |
IsPgVectorAvailable | Returns if the pgvector extension is detected as installed |
SqlGenerator | A SqlGenerator for the currently connected database |
Methods
| Name | Description |
|---|---|
string BuildConnectionString(DatabaseConfig dbConfig) | Builds a PostgreSQL specific connection string based on provided Database Configuration |
string BuildConnectionString(string server, string database, IAuthenticationCredential credentials, IReadOnlyDictionary<string, string> configParams, int port = null) | Builds a PostgreSQL specific connection string based on provided values Supports SQL authentication (Basic/NTLM) and Azure Entra ID via PostgreSqlAzureCredentials. |
bool ChangeDatabase(string database) | Change to the requested database |
bool CheckDatabaseExist(string name) | Check if the specified database exist |
bool CheckExtensionInstalled(string extension) | Returns true if the specified extension is currently installed in the connected database. |
Task<bool> CheckExtensionInstalledAsync(string extension, CancellationToken cancellationToken = null) | Asynchronously returns true if the specified extension is currently installed in the connected database. |
bool CheckSchemaExist(string schema) | Checks if the specified Schema exist in the database |
bool CheckTableExist(string table, string schema = null) | Checks if the specified Table exist in the database |
Task<bool> CheckTableExistAsync(string table, string schema = null) | Checks if the specified Table exist in the database |
Task<bool> ClearServerCacheAsync(CancellationToken cancellationToken = null) | Drops information about the current connection from Server Config Cache resulting in a refresfh of data on any subsequent access |
bool CreateExtension(string extension, string schema = null) | Installs the specified PostgreSQL extension if it is not already present. |
Task<bool> CreateExtensionAsync(string extension, string schema = null) | Asynchronously installs the specified PostgreSQL extension if it is not already present. |
bool CreateSchema(string name, string authorization = null, string comment = null) | Create a schema in the database |
Task<bool> CreateSchemaAsync(string name, string authorization = null, string comment = null) | Create a schema in the database |
Task<bool> CreateSequenceAsync(string name, int seed) | Asynchronously creates a named sequencer. |
Task<bool> DropConstraintAsync(Constraint constraint) | Drop the requested Constraint from the table |
Task<bool> DropConstraintAsync(ISelectable selectable, string constraint) | Drop the requested Constraint from the table |
Task<bool> DropConstraintAsync(string table, string constraint) | Drop the requested Constraint from the table |
bool DropExtension(string extension) | Deletes the specified PostgreSQL extension if it is not already present. |
Task<bool> DropExtensionAsync(string extension) | Asynchronously deletes the specified PostgreSQL extension if it is not already present. |
bool DropSchema(string schema) | Execute a DROP command for the specified schema |
Task<bool> DropSchemaAsync(string schema) | Execute a DROP command for the specified schema |
Task<bool> DropSequenceAsync(string name) | Asynchronously drops the specified PostgreSQL sequence if it exists. |
bool DropTables(IEnumerable<string> tables) | Execute a DROP command for multiple tables |
Task<bool> DropTablesAsync(IEnumerable<string> tables) | Execute a DROP command for multiple tables |
Guid GenerateUuid() | Generate a UUID byte ordered for the current connection type |
IReadOnlyList<string> GetAvailableExtensions(bool forceRefresh = null) | Returns available Extensions |
Task<IReadOnlyList<string>> GetAvailableExtensionsAsync(bool forceRefresh = null, CancellationToken cancellationToken = null) | Asynchronously returns available Extensions |
IReadOnlyList<string> GetAvailableFtsLanguages(bool forceRefresh = null) | Returns a list of configured languages (text search configurations) available for full-text search queries. |
Task<IReadOnlyList<string>> GetAvailableFtsLanguagesAsync(bool forceRefresh = null, CancellationToken cancellationToken = null) | Asynchronously returns a list of configured languages (text search configurations) available for full-text search queries. |
string GetCollation() | Returns the Collation for the current connection |
string GetCollation(string database) | Returns the Collation for the current connection |
Task<string> GetCollationAsync() | Returns the Collation for the current connection |
Task<string> GetCollationAsync(string database) | Returns the Collation for the current connection |
Task<IReadOnlyList<Constraint>> GetConstraintsAsync(ISelectable selectable, int commandTimeout = null) | Returns constraints for the given table. Empty list when the table is missing or has none (never null on success). |
Task<IReadOnlyList<Constraint>> GetConstraintsAsync(int commandTimeout = null) | Returns constraints in the database. Empty list when none exist (never null on success). |
Task<IReadOnlyList<Constraint>> GetConstraintsAsync(string schema, int commandTimeout = null) | Returns constraints filtered by schema. Empty list when the schema is missing or has none (never null on success). |
string GetExtensionSchema(string extension) | Returns the schema that owns the specified installed extension, or if it is not installed. |
Task<string> GetExtensionSchemaAsync(string extension, CancellationToken cancellationToken = null) | Asynchronously returns the schema that owns the specified installed extension, or if it is not installed. |
Task<IReadOnlyList<IndexInformation>> GetIndexesAsync(int commandTimeout = null) | Retrieve all indexes from the database. Empty list when none exist (never null on success). |
Task<IReadOnlyList<IndexInformation>> GetIndexesAsync(string schema, int commandTimeout = null) | Retrieve indexes from a specific database schema. Empty list when none exist (never null on success). |
Task<IReadOnlyList<IndexInformation>> GetIndexesByTable(ITableInfo table, int commandTimeout = null) | Retrieve indexes for a specific table. Empty list when none exist (never null on success). |
IReadOnlyList<string> GetInstalledExtensions(bool forceRefresh = null) | Returns a list of extensions installed on the current Connection |
Task<IReadOnlyList<string>> GetInstalledExtensionsAsync(bool forceRefresh = null, CancellationToken cancellationToken = null) | Asynchronously returns a list of extensions installed on the current Connection |
Type GetParameterType() | Returns Type data for the connections underlying DbParameter implementation |
int GetPid() | Obtain the connections Process ID |
Task<int> GetPidAsync() | Obtain the connections Process ID |
PgSequencer GetSequence(string name) | Returns the details of SEQUENCE |
Task<PgSequencer> GetSequenceAsync(string name) | Asynchronously returns the details of SEQUENCE |
IReadOnlyList<string> GetSequenceList() | Returns the names SEQUENCE objects in the current database |
IReadOnlyList<string> GetSequenceList(string schema) | Returns the names SEQUENCE objects in the current database filtered by schema |
Task<IReadOnlyList<string>> GetSequenceListAsync() | Asynchronously returns the names SEQUENCE objects in the current database |
Task<IReadOnlyList<string>> GetSequenceListAsync(string schema) | Asynchronously returns the names SEQUENCE objects in the current database filtered by schema |
TableInfo GetTableInfo(string schema, string table, bool includeIndexes, bool includeConstraints, int commandTimeout = null) | Returns information about the specified database table |
Task<IReadOnlyList<TableInfo>> GetTableInfoAsync(string schema, bool includeIndexes, bool includeConstraints, int commandTimeout = null) | Returns information about the specified database table |
Task<TableInfo> GetTableInfoAsync(string schema, string table, bool includeIndexes, bool includeConstraints, int commandTimeout = null) | Returns information about the specified database table |
IReadOnlyList<string> GetTableList(int commandTimeout = null) | Returns a List of tables in the current database |
IReadOnlyList<string> GetTableList(string schema, int commandTimeout = null) | Returns a List of tables limited by the schema name |
Task<IReadOnlyList<string>> GetTableListAsync(string schema, int commandTimeout = null) | Returns a List of tables limited by the schema name |
string GetVersion() | Returns version of the current database in string format |
Task<string> GetVersionAsync() | Returns version of the current database in string format |
bool Open() | Attempt to Open connection to the Database if it is not already in an Open state |
Task<bool> OpenAsync(CancellationToken cancellationToken = null) | Open the connection asynchronously if not already open. |
string PhraseToTsQuery(string phrase, string language = null) | Converts a natural language phrase into a full-text search query (e.g., for use with tsquery operations). |
Task<string> PhraseToTsQueryAsync(string phrase, string language = null) | Asynchronously converts a natural language phrase into a full-text search query (e.g., for use with tsquery operations). |
void ReloadTypes() | Reloads Npgsql's type cache for this connection. |
Task ReloadTypesAsync(CancellationToken cancellationToken = null) | Asynchronously reloads Npgsql's type cache for this connection. |