If you want to use field names with hyphens when updating firestore data in python

I searched around because I didn't know the solution last time, so I write a qiita article so that it can be easily hit by google search. Borrow Qiita SEO.

TL;DR Surround with back quotes!

db.collection('users').document('AAAAABBBBB').update({
   u"status.`xxxx-yyyyy-zzzz`": "hogehoge"
})

Commentary

If you write the code below with the usual glue, it will get stuck.

db.collection('users').document('AAAAABBBBB').update({
   u"status.xxxx-yyyyy-zzzz": "hogehoge"
})
ValueError: Non-alphanum char in element with leading alpha: xxxx-yyyyy-zzzz

reference

https://github.com/googleapis/google-cloud-python/issues/8086

Recommended Posts

If you want to use field names with hyphens when updating firestore data in python
Solution when you want to use cv_bridge with python3 (virtualenv)
[Python] When you want to use all variables in another file
I know? Data analysis using Python or things you want to use when you want with numpy
If you want to count words in Python, it's convenient to use Counter.
Use PIL in Python to extract only the data you want from Exif
If you want to make a discord bot with python, let's use a framework
What to do if you don't want to use Japanese column names when using ortoolpy.logistics_network
Use aggdraw when you want to draw beautifully with pillow
When you want to register Django's initial data with relationships
[Python] When you want to import and use your own package in the upper directory
[Subprocess] When you want to execute another Python program in Python code
If you want to become a data scientist, start with Kaggle
Don't write Python if you want to speed it up with Python
If you want to assign csv export to a variable in python
What to do if you can't use scikit grid search in Python
When you want to use it as it is when using it with lambda memo
Gist repository to use when you want to try a little with ansible
If you want to include awsebcli with CircleCI, specify the python version
If you want to get multiple statistics with groupby in pandas v1
I want to use MATLAB feval with python
I want to use Temporary Directory with Python2
How to use tkinter with python in pyenv
Two document generation tools that you definitely want to use if you write python
How to build an environment when you want to use python2.7 after installing Anaconda3
[OpenCV] When you want to check if it is read properly with imread
What to do if you get an error when installing python with pyenv
If you use Pandas' Plot function in Python, it is really seamless from data processing to graph creation
If you want to use Cython, also include python-dev
When you want to filter with Django REST framework
I want to work with a robot in python.
Site notes to help you use NetworkX with Python
I want to use the R dataset in python
I want to do something in Python when I finish
[Python] I want to use only index when looping a list with a for statement
What to do if you get an OpenSSL error when installing Python 2 with pyenv
I want to use a python data source in Re: Dash to get query results
What to do if you get an error when importing matplotlib in Python (Mac)
What to do if you run python in IntelliJ and end with an error
A convenient function memo to use when you want to enter the debugger if an error occurs when running a Python script.
[Django] A memorandum when you want to communicate asynchronously [Python3]
I want to be able to analyze data with Python (Part 3)
[AWS] What to do when you want to pip with Lambda
[Python] If you suddenly want to create an inquiry form
Knowledge you need to know when programming competitive programming with Python2
I want to be able to analyze data with Python (Part 1)
[python] A note when trying to use numpy with Cython
Useful operation when you want to solve all problems in multiple programming languages with Codewars
[Road to intermediate Python] Use if statement in list comprehension
I want to be able to analyze data with Python (Part 2)
[Python] I want to use the -h option with argparse
[Python3] Code that can be used when you want to resize images in folder units
Things to keep in mind when using Python with AtCoder
When you want to use python2.x on modern Gentoo Linux
If you want your colleagues to use the same language
Things to keep in mind when using cgi with python.
When you want to hit a UNIX command on Python
If you can't use Beautiful Soup 4 after updating to Python 3.5. ImportError: No module named bs4
What to do if you get an Undefined error when trying to use pip with pyenv
How to write when you want to put a number after the group number to be replaced with a regular expression in re.sub of Python
I want to improve efficiency with Python even in an experimental system (4) Use ser.close () when an error is thrown using try syntax