If output to the terminal, the following would display. This action retrieves the Field Names from the Table and saves the results to tbl_fields. ![]() The following lines access and retrieve the scription field using a lambda, a map(), and a list. A Cursor Object is created from these results and saved to cols. The first two (2) lines in the above code snippet execute and commit a SQL command that receives all rows from the inventory Table. cols = conn.execute('SELECT * FROM inventory')Ĭol_names = list(map(lambda x: x, scription)) Paste the following lines to the bottom of the cars-sql.py file. This section shows how to retrieve a list of the Column Names in the Table. If successful, the cars.db SQLite database should now reside in the current working directory. The Cursor Object allows access to commands, such as SQL, which can be applied against the Database and/or Table. The last line creates a Cursor Object ( cur) from the Connection Object ( conn).
0 Comments
Leave a Reply. |