You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -1648,10 +1648,10 @@ The schema of the above table is:
1648
1648
1649
1649
.. code-block:: sql
1650
1650
1651
-
CREATETABLE[Trees] (
1652
-
[id]INTEGERPRIMARYKEY,
1653
-
[TreeAddress]TEXT,
1654
-
[Species]TEXT
1651
+
CREATETABLE"Trees" (
1652
+
"id"INTEGERPRIMARYKEY,
1653
+
"TreeAddress"TEXT,
1654
+
"Species"TEXT
1655
1655
)
1656
1656
1657
1657
Here's how to extract the ``Species`` column using ``.extract()``:
@@ -1665,19 +1665,19 @@ After running this code the table schema now looks like this:
1665
1665
.. code-block:: sql
1666
1666
1667
1667
CREATETABLE"Trees" (
1668
-
[id]INTEGERPRIMARYKEY,
1669
-
[TreeAddress]TEXT,
1670
-
[Species_id]INTEGER,
1668
+
"id"INTEGERPRIMARYKEY,
1669
+
"TreeAddress"TEXT,
1670
+
"Species_id"INTEGER,
1671
1671
FOREIGN KEY(Species_id) REFERENCES Species(id)
1672
1672
)
1673
1673
1674
1674
A new ``Species`` table will have been created with the following schema:
1675
1675
1676
1676
.. code-block:: sql
1677
1677
1678
-
CREATETABLE[Species] (
1679
-
[id]INTEGERPRIMARYKEY,
1680
-
[Species]TEXT
1678
+
CREATETABLE"Species" (
1679
+
"id"INTEGERPRIMARYKEY,
1680
+
"Species"TEXT
1681
1681
)
1682
1682
1683
1683
The ``.extract()`` method defaults to creating a table with the same name as the column that was extracted, and adding a foreign key column called ``tablename_id``.
@@ -1693,15 +1693,15 @@ The resulting schema looks like this:
The table name ``CommonName_LatinName``is derived from the extract columns. You can use ``table=``and``fk_column=`` to specify custom names like this:
@@ -1748,15 +1748,15 @@ This produces the following schema:
1748
1748
.. code-block:: sql
1749
1749
1750
1750
CREATETABLE"Trees" (
1751
-
[id]INTEGERPRIMARYKEY,
1752
-
[TreeAddress]TEXT,
1753
-
[species_id]INTEGER,
1751
+
"id"INTEGERPRIMARYKEY,
1752
+
"TreeAddress"TEXT,
1753
+
"species_id"INTEGER,
1754
1754
FOREIGN KEY(species_id) REFERENCES Species(id)
1755
1755
)
1756
-
CREATETABLE[Species] (
1757
-
[id]INTEGERPRIMARYKEY,
1758
-
[CommonName]TEXT,
1759
-
[LatinName]TEXT
1756
+
CREATETABLE"Species" (
1757
+
"id"INTEGERPRIMARYKEY,
1758
+
"CommonName"TEXT,
1759
+
"LatinName"TEXT
1760
1760
)
1761
1761
1762
1762
You can use the ``rename=`` argument to rename columns in the lookup table. To create a ``Species`` table with columns called ``name``and``latin`` you can do this:
@@ -1774,10 +1774,10 @@ This produces a lookup table like so:
1774
1774
1775
1775
.. code-block:: sql
1776
1776
1777
-
CREATETABLE[Species] (
1778
-
[id]INTEGERPRIMARYKEY,
1779
-
[name]TEXT,
1780
-
[latin]TEXT
1777
+
CREATETABLE"Species" (
1778
+
"id"INTEGERPRIMARYKEY,
1779
+
"name"TEXT,
1780
+
"latin"TEXT
1781
1781
)
1782
1782
1783
1783
.. _python_api_hash:
@@ -2100,12 +2100,12 @@ The ``.schema`` property outputs the table's schema as a SQL string::
@@ -2507,9 +2507,9 @@ This will create the ``_counts`` table if it does not already exist, with the fo
2507
2507
2508
2508
.. code-block:: sql
2509
2509
2510
-
CREATETABLE[_counts] (
2511
-
[table]TEXTPRIMARYKEY,
2512
-
[count]INTEGERDEFAULT0
2510
+
CREATETABLE"_counts" (
2511
+
"table"TEXTPRIMARYKEY,
2512
+
"count"INTEGERDEFAULT0
2513
2513
)
2514
2514
2515
2515
You can enable cached counts for every table in a database (exceptfor virtual tables and the ``_counts`` table itself) using the database ``enable_counts()`` method:
@@ -2719,11 +2719,11 @@ For example:
2719
2719
2720
2720
# The table schema looks like this:
2721
2721
# print(db.table("cats").schema)
2722
-
# CREATE TABLE [cats] (
2723
-
#[id] INTEGER PRIMARY KEY,
2724
-
#[name] TEXT,
2725
-
#[age] INTEGER,
2726
-
#[thumbnail] BLOB
2722
+
# CREATE TABLE "cats" (
2723
+
#"id" INTEGER PRIMARY KEY,
2724
+
#"name" TEXT,
2725
+
#"age" INTEGER,
2726
+
#"thumbnail" BLOB
2727
2727
# )
2728
2728
2729
2729
.. _python_api_register_function:
@@ -2887,9 +2887,9 @@ If we insert this data directly into a table we will get a schema that is entire
2887
2887
db.table("creatures").insert_all(rows)
2888
2888
print(db.schema)
2889
2889
# Outputs:
2890
-
# CREATE TABLE [creatures] (
2891
-
#[id] TEXT,
2892
-
#[name] TEXT
2890
+
# CREATE TABLE "creatures" (
2891
+
#"id" TEXT,
2892
+
#"name" TEXT
2893
2893
# );
2894
2894
2895
2895
We can detect the best column types using a ``TypeTracker`` instance:
@@ -2910,9 +2910,9 @@ We can then apply those types to our new table using the :ref:`table.transform()
0 commit comments