mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-07-23 01:14:31 +02:00
.table_names and .tables properties plus expanded docs
This commit is contained in:
parent
f4907f6df5
commit
515d362ad6
5 changed files with 54 additions and 11 deletions
|
|
@ -1,8 +1,8 @@
|
|||
=======
|
||||
Table
|
||||
=======
|
||||
======================
|
||||
Databases and Tables
|
||||
======================
|
||||
|
||||
Tables are accessed using the indexing operator, like so:
|
||||
Database objects are constructed by passing in a SQLite3 database connection:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
|
|
@ -10,10 +10,28 @@ Tables are accessed using the indexing operator, like so:
|
|||
import sqlite3
|
||||
|
||||
db = Database(sqlite3.connect("my_database.db"))
|
||||
|
||||
Tables are accessed using the indexing operator, like so:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
table = db["my_table"]
|
||||
|
||||
If the table does not yet exist, it will be created the first time you attempt to insert or upsert data into it.
|
||||
|
||||
Listing tables
|
||||
==============
|
||||
|
||||
You can list the names of tables in a database using the ``.table_names`` property::
|
||||
|
||||
>>> db.table_names
|
||||
['dogs']
|
||||
|
||||
You can also iterate through the table objects themselves using ``.tables``::
|
||||
|
||||
>>> db.tables
|
||||
[<Table dogs>]
|
||||
|
||||
Creating tables
|
||||
===============
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue