Added
-
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 the
pandas.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.
Changed
-
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__
.
Fixed
-
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.
-
Deprecated
-
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.