All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
- A
DatabaseManager
for Microsoft SQL Server.
1.2.0 - 2023-02-06
New methods for DatabaseManager
and improved performance!
-
DatabaseManager.upsert_table()
: Update a table with data from apandas.DataFrame
and insert new rows if any. -
DatabaseManager.merge_table()
: Merge data from apandas.DataFrame
into a table. -
DatabaseManager.save_df()
:-
Added the 'drop-replace' option to the
if_exists
parameter, which drops the table, recreates it, and then writes thepandas.DataFrame
to the table. -
Added the parameters
datetime_cols_dtype
,datetime_format
,localize_tz
andtarget_tz
, which allows adjusting the timezone and data type of datetime columns before saving thepandas.DataFrame
to the database.
-
-
DatabaseManager.load_table()
: Added the parametersdatetime_cols_dtype
anddatetime_format
, which allows adjusting the data type of datetime columns from the loadedpandas.DataFrame
. -
InvalidColumnNameError
: Exception raised when supplying an invalid column name to a database operation. -
SQLStatementNotSupportedError
: Exception raised when executing a method that triggers a SQL statement not supported by the database dialect. E.g. a merge statement.
-
The
DatabaseManager
base class is now a proper class and not an ABC. It can now be initialized from a SQLAlchemy URL or Engine. This is useful if you want to use Pandemy, but there is no subclass ofDatabaseManager
implemented for the desired SQL dialect. It should only be used directly if there is no dedicated subclass since it has limited functionality. -
DatabaseManager
and its subclasses now use__slots__
, which improves performance of attribute access and lowers memory usage. -
SQLiteDb
andOracleDb
now support to be initialized with a SQLAlchemy connection URL or Engine. -
Placeholder
has been refactored from anamedtuple
into a proper class that is using__slots__
.
-
DatabaseManager.save_df()
:-
The option 'replace' of the
if_exists
parameter now correctly deletes the data of the existing table before writing thepandas.DataFrame
instead of dropping the table, recreating it, and finally writing thepandas.DataFrame
to the table. The old behavior has been moved to the 'drop-replace' option (see section Added above). -
The method now correctly raises
TableExistsError
andSaveDataFrameError
. AValueError
raised by thepandas.DataFrame.to_sql()
method, that is not related to "table exists and if_exists='fail'", is now translated into aSaveDataFrameError
and not aTableExistsError
as before.
-
-
The methods
OracleDb.from_url()
andOracleDb.from_engine()
are now deprecated since their functionality is now fulfilled by theurl
andengine
parameters added to the original constructor. -
The
SQLiteDb.conn_str
attribute is deprecated and replaced by theurl
attribute.
1.1.0 - 2022-04-09
Support for Oracle databases!
-
OracleDb
: The Oracle DatabaseManager.OracleDb
also introduces the alternative constructor methodsfrom_url()
andfrom_engine()
, which create an instance ofOracleDb
from an existing SQLAlchemy connection URL or engine respectively. -
CreateConnectionURLError
: An exception raised if there are errors when creating aDatabaseManager
from a SQLAlchemy connection URL.
1.0.0 - 2022-02-12
The first major release of Pandemy!
-
DatabaseManager
: The base class with functionality for managing a database. Each database type will subclass fromDatabaseManager
and implement the initializer which is specific to each database type.DatabaseManager
is never used on its own, but merely provides the methods to interact with the database to its subclasses. The following methods are available:-
delete_all_records_from_table()
: Delete all records from an existing table in the database. -
execute()
: Execute a SQL statement on the database. -
load_table()
: Load a table by name or SQL query into apandas.DataFrame
. -
manage_foreign_keys()
: Manage how the database handles foreign key constraints. Implementation in each subclass. -
save_df()
: Save apandas.DataFrame
to a table in the database.
-
-
SQLiteDb
: The SQLiteDatabaseManager
.manage_foreign_keys()
: In SQLite the check of foreign key constraints is not enabled by default.
-
SQLContainer
: A storage container for the SQL statements used by aDatabaseManager
. Each SQL-dialect will subclass fromSQLContainer
andSQLContainer
is never used on its own, but merely provides methods to work with SQL statements. Each SQL statement is implemented as a class variable.replace_placeholders()
: Replace placeholders in a SQL statement. The main purpose of the method is to handle parametrized IN statements with a variable number of values.
-
Placeholder
: Container of placeholders and their replacement values for parametrized SQL statements. Used as input toSQLContainer.replace_placeholders()
. -
PandemyError
: The base Exception of Pandemy.-
InvalidInputError
: Invalid input to a function or method. -
DatabaseManagerError
: Base Exception for errors related to theDatabaseManager
class.-
CreateEngineError
: Error when creating the database engine. -
DatabaseFileNotFoundError
: Error when the file of a SQLite database cannot be found. -
DataTypeConversionError
: Errors when converting data types of columns in apandas.DataFrame
. -
DeleteFromTableError
: Errors when deleting data from a table in the database. -
ExecuteStatementError
: Errors when executing a SQL statement with aDatabaseManager
. -
InvalidTableNameError
: Errors when supplying an invalid table name to a database operation. -
LoadTableError
: Errors when loading tables from the database. -
SaveDataFrameError
: Errors when saving apandas.DataFrame
to a table in the database. -
SetIndexError
: Errors when setting an index of apandas.DataFrame
after loading a table from the database. -
TableExistsError
: Errors when saving apandas.DataFrame
to a table and the table already exists.
-
-
0.0.1 - 2021-05-18
-
The initial structure of the project.
-
Registration on PyPI.