html_url,issue_url,id,node_id,user,created_at,updated_at,author_association,body,reactions,issue,performed_via_github_app
https://github.com/simonw/sqlite-utils/issues/86#issuecomment-591770623,https://api.github.com/repos/simonw/sqlite-utils/issues/86,591770623,MDEyOklzc3VlQ29tbWVudDU5MTc3MDYyMw==,9599,2020-02-27T04:12:39Z,2020-02-27T04:12:39Z,OWNER,"I pushed a branch with my experiment in it, but I'm going to fix this by throwing an error on `[` or `]` in a column name instead - I won't implement the changes from that branch.","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",564579430,
https://github.com/simonw/sqlite-utils/issues/86#issuecomment-586729798,https://api.github.com/repos/simonw/sqlite-utils/issues/86,586729798,MDEyOklzc3VlQ29tbWVudDU4NjcyOTc5OA==,9599,2020-02-16T17:11:02Z,2020-02-16T17:11:02Z,OWNER,I filed a bug in the Python issue tracker here: https://bugs.python.org/issue39652,"{""total_count"": 2, ""+1"": 2, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",564579430,
https://github.com/simonw/sqlite-utils/issues/86#issuecomment-586676856,https://api.github.com/repos/simonw/sqlite-utils/issues/86,586676856,MDEyOklzc3VlQ29tbWVudDU4NjY3Njg1Ng==,9599,2020-02-16T07:20:34Z,2020-02-16T07:20:34Z,OWNER,"I'm not sure what to do about this one.
I can't fix it: this bug in Python's `sqlite3` module means that even if I write a database out with column names that include `[]` I won't be able to read them back again.
So... I could do one of the following:
- Throw an error if a column name includes those characters. That's my preferred option I think.
- Automatically replace `[` in column names with `(` and `]` with `)`
- Do the automatic replacement but show a user-visible warning when I do it
- Throw an error, but give the user an option to run with e.g. `--fix-column-names` which applies that automatic fix.
Since this is likely to be an incredibly rare edge-case I think I'd rather minimize the amount of code that deals with it, so my preferred option is to just throw that error and stop.","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",564579430,
https://github.com/simonw/sqlite-utils/issues/86#issuecomment-586676640,https://api.github.com/repos/simonw/sqlite-utils/issues/86,586676640,MDEyOklzc3VlQ29tbWVudDU4NjY3NjY0MA==,9599,2020-02-16T07:16:31Z,2020-02-16T07:16:31Z,OWNER,"There's something weird about this. I created a test database file like so:
```
sqlite3 /tmp/demo.db < .schema
CREATE TABLE IF NOT EXISTS ""data"" (
""MTU (CET)"" TEXT,
""Day-ahead Price [EUR/MWh]"" TEXT
);
sqlite> .headers on
sqlite> select * from data;
MTU (CET)|Day-ahead Price [EUR/MWh]
01.01.2016 00:00 - 01.01.2016 01:00|23.86
sqlite>
```
BUT... if I open the same database in Python, something weird happens:
```
In [1]: import sqlite3
In [2]: conn = sqlite3.connect(""/tmp/demo.db"")
In [3]: cursor = conn.cursor()
In [4]: cursor.execute(""select * from data"")
Out[4]:
In [5]: cursor.fetchall()
Out[5]: [('01.01.2016 00:00 - 01.01.2016 01:00', '23.86')]
In [6]: cursor.description
Out[6]:
(('MTU (CET)', None, None, None, None, None, None),
('Day-ahead Price', None, None, None, None, None, None))
In [7]: conn.row_factory = sqlite3.Row
In [8]: cursor = conn.cursor()
In [9]: cursor.execute(""select * from data"")
Out[9]:
In [10]: row = cursor.fetchall()
In [12]: row
Out[12]:
In [15]: row.keys()
Out[15]: ['MTU (CET)', 'Day-ahead Price']
```
Note that in `cursor.description` AND in `row.keys()` above the second column is displayed as `'Day-ahead Price'` - when we would expect it to be displayed as `Day-ahead Price [EUR/MWh]`
So.... it looks like there may be a bug in Python's `sqlite3` module where columns with square braces in them have that portion of the name stripped out!","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",564579430,
https://github.com/simonw/sqlite-utils/issues/86#issuecomment-586662404,https://api.github.com/repos/simonw/sqlite-utils/issues/86,586662404,MDEyOklzc3VlQ29tbWVudDU4NjY2MjQwNA==,9599,2020-02-16T02:43:12Z,2020-02-16T02:43:12Z,OWNER,"https://stackoverflow.com/a/22694438 looks like the answer:
> When using square brackets, it is not possible to have these characters in the identifier.
>
> When using double quotes, you can escape them in the name by doubling them:
>
> `CREATE TABLE ""hello """"world""""""(key INTEGER PRIMARY KEY);`","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",564579430,
https://github.com/simonw/sqlite-utils/issues/86#issuecomment-586661934,https://api.github.com/repos/simonw/sqlite-utils/issues/86,586661934,MDEyOklzc3VlQ29tbWVudDU4NjY2MTkzNA==,9599,2020-02-16T02:33:07Z,2020-02-16T02:33:07Z,OWNER,"Thanks for the example file - looks like it can be trimmed down to just these two lines to replicate the bug:
```csv
""MTU (CET)"",""Day-ahead Price [EUR/MWh]""
""01.01.2016 00:00 - 01.01.2016 01:00"",""23.86""
```","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",564579430,