polars.DataFrame.write_database#

DataFrame.write_database(table_name: str, connection_uri: str, *, if_exists: DbWriteMode = 'fail', engine: DbWriteEngine = 'sqlalchemy') None[source]#

Write a polars frame to a database.

Parameters:
table_name

Name of the table to append to or create in the SQL database.

connection_uri

Connection uri, for example

  • “postgresql://username:password@server:port/database”

if_exists{‘append’, ‘replace’, ‘fail’}

The insert mode. ‘replace’ will create a new database table, overwriting an existing one. ‘append’ will append to an existing table. ‘fail’ will fail if table already exists.

engine{‘sqlalchemy’, ‘adbc’}

Select the engine used for writing the data.