atoti.Table.load_sql()#

Table.load_sql(sql, *, url, driver=None)#

Load the result of the passed SQL query into the table.

Note

This method requires the atoti-jdbc plugin.

Parameters:
  • sql (str) – The result of this SQL query will be loaded into the table.

  • url (str) –

    The JDBC connection string of the database. The jdbc: prefix is optional but the database specific part (such as h2: or mysql:) is mandatory. For instance:

    • h2:file:/home/user/database/file/path;USER=username;PASSWORD=passwd

    • mysql://localhost:7777/example?user=username&password=passwd

    • postgresql://postgresql.db.server:5430/example?user=username&password=passwd

    More examples can be found here.

  • driver (str | None) –

    The driver used to load the data.

    If None, it is inferred from url.

Example

>>> table = session.create_table("Cities", types={"ID": tt.INT, "CITY": tt.STRING, "MY_VALUE": tt.DOUBLE}, keys=["ID"])
>>> table.load_sql(
...     "SELECT * FROM MYTABLE;",
...     url=f"h2:file:{RESOURCES_PATH}/h2-database;USER=root;PASSWORD=pass",
... )
>>> table.row_count
5