from_sql(conn, sql_statement, params=None, type_inference_rows=100, dbapi_module=None, column_type_hints=None, cursor_arraysize=128)¶
Convert the result of a SQL database query to an SFrame.
- conn : dbapi2.Connection
A DBAPI2 connection object. Any connection object originating from the ‘connect’ method of a DBAPI2-compliant package can be used.
- sql_statement : str
The query to be sent to the database through the given connection. No checks are performed on the sql_statement. Any side effects from the query will be reflected on the database. If no result rows are returned, an empty SFrame is created.
- params : iterable | dict, optional
Parameters to substitute for any parameter markers in the sql_statement. Be aware that the style of parameters may vary between different DBAPI2 packages.
- type_inference_rows : int, optional
The maximum number of rows to use for determining the column types of the SFrame. These rows are held in Python until all column types are determined or the maximum is reached.
- dbapi_module : module | package, optional
The top-level DBAPI2 module/package that constructed the given connection object. By default, a best guess of which module the connection came from is made. In the event that this guess is wrong, this will need to be specified.
- column_type_hints : dict | list | type, optional
Specifies the types of the output SFrame. If a dict is given, it must have result column names as keys, but need not have all of the result column names. If a list is given, the length of the list must match the number of result columns. If a single type is given, all columns in the output SFrame will be this type. If the result type is incompatible with the types given in this argument, a casting error will occur.
- cursor_arraysize : int, optional
The number of rows to fetch from the database at one time.
- out : SFrame
>>> import sqlite3
>>> conn = sqlite3.connect('example.db')
>>> turicreate.SFrame.from_sql(conn, "SELECT * FROM foo") Columns: a int b int Rows: 1 Data: +---+---+ | a | b | +---+---+ | 1 | 2 | +---+---+ [1 rows x 2 columns]