# Titling sqlite3 table columns with number

**URL:** <https://discuss.python.org/t/titling-sqlite3-table-columns-with-number/13656>\
**Category:** Python Help\
**Tags:** help\
**Created:** [February 11, 2022, 11:13am UTC](https://discuss.python.org/t/titling-sqlite3-table-columns-with-number/13656 "2022-02-11T11:13:48Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![py\_leo80](https://avatars.discourse-cdn.com/v4/letter/p/f19dbf/32.png) [@py\_leo80](https://discuss.python.org/u/py_leo80)\
**Post date:** [February 11, 2022, 11:13am UTC](https://discuss.python.org/t/titling-sqlite3-table-columns-with-number/13656/1 "2022-02-11T11:13:48Z")

</div>

I got a tuple whose elements are int or real numbers and I need to create a sqlite3 table assigning to each column name the correspondent element into the tuple.

Here’s my code:

```auto
fAEHz=('20','25','31.5','40','50','63')
conn = sqlite3.connect('daticert.db')
cur = conn.cursor()
columns = " TEXT, ".join([str(freq) for freq in fAEHz])
command = "CREATE TABLE IF NOT EXISTS mk221ae (" + columns + " TEXT)"
cur.execute(command)
conn.commit()

```

There’s something wrong since I got the following message:

```auto
", line 293, in <module>
    cur.execute(command)
sqlite3.OperationalError: near "20": syntax error

```

If I use a tuple whose elements are strings (as shown below), everything works fine!

```auto
fAEHz = ["Name", "Address", "Email", "Phone"]

```

Is there any solution or it is forbidden to give sqlite3 column name a number?  
Thank you ever so much.

---

<div class="post-metadata">

**Author:** ![erlendaasland](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/erlendaasland/32/4378_2.png) [@erlendaasland](https://discuss.python.org/u/erlendaasland)\
**Post date:** [February 11, 2022, 12:07pm UTC](https://discuss.python.org/t/titling-sqlite3-table-columns-with-number/13656/2 "2022-02-11T12:07:13Z")

</div>

SQLite does not accept integers as column (or table) names. (I’m not sure if any SQL dialect actually do.) As an exercise, try writing these queries out directly in the SQLite CLI.

If you _really_ want numbers as column names, you’ll have to write them as string literals. I leave that also as an exercise for the reader 🙂

---

<div class="post-metadata">

**Author:** ![erlendaasland](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/erlendaasland/32/4378_2.png) [@erlendaasland](https://discuss.python.org/u/erlendaasland)\
**Post date:** [February 11, 2022, 12:11pm UTC](https://discuss.python.org/t/titling-sqlite3-table-columns-with-number/13656/3 "2022-02-11T12:11:28Z")

</div>

Slightly related: perhaps we should revive [bpo-33436: Add an interactive shell for Sqlite3](https://bugs.python.org/issue33436)? It could make it easier for users to experiment with and test out queries while developing.

---

<div class="post-metadata">

**Author:** ![stonebig](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/stonebig/32/2796_2.png) [@stonebig](https://discuss.python.org/u/stonebig)\
**Post date:** [February 12, 2022, 2:42pm UTC](https://discuss.python.org/t/titling-sqlite3-table-columns-with-number/13656/4 "2022-02-12T14:42:06Z")

</div>

Having python, sqlite3.dll, and no simpler battery included way to explore datas with this, is a crime

---

<div class="post-metadata">

**Author:** ![erlendaasland](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/erlendaasland/32/4378_2.png) [@erlendaasland](https://discuss.python.org/u/erlendaasland)\
**Post date:** [July 19, 2022, 11:03pm UTC](https://discuss.python.org/t/titling-sqlite3-table-columns-with-number/13656/5 "2022-07-19T23:03:06Z")

</div>

Crime or not; there’s a draft PR for an interactive sqlite3 shell now:

> <https://github.com/python/cpython/pull/95026>
>
> Resolves gh-77617
