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-sqlplugin.- 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 ash2:ormysql:) is mandatory. For instance:h2:file:/home/user/database/file/path;USER=username;PASSWORD=passwdmysql://localhost:7777/example?user=username&password=passwdpostgresql://postgresql.db.server:5430/example?user=username&password=passwd
More examples can be found here.
driver (str | None) – The JDBC driver used to load the data. If
None, the driver is inferred from the URL. Drivers can be found in theatoti_sql.driversmodule.
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}/h2-database;USER=root;PASSWORD=pass", ... ) >>> len(table) 5