In this video, Jennifer Harrison explains how to write a SQL statement inside of Python. Learn how to format the SQL statement so that it can be taken into ArcMap.
- [Instructor] Let's look at a couple…of special situations for working with strings in Python.…First we'll look at building a SQL query…that can be passed to ArcMap,…and then we'll look at string slicing,…which means pulling out a portion of a string.…Suppose a SQL query needs to be built…that needs to say flood status equals 100 year.…There are some other cases where special…characters need to be protected in Python.…Suppose, for example, a SQL query needs to be built…that is going to be passed into ArcMap.…
Suppose the query needs to say…flood status equals 100 years.…So something like this,…string SQL query, that variable, is equal to…flood status equals 100 year.…So that's the string we need to pass into ArcMap,…but this won't work because Python thinks its…got two equal signs in there.…I need to somehow protect the entire SQL query…and I do that by putting a pair of quotes around the query.…
So I put some quotes on the outside…and put some quotes at the beginning as well.…But that's gonna cause a problem too,…
- Writing and running Python scripts in IDLE
- Making scripts flexible with variables
- Commenting scripts
- Manipulating string data
- Object-oriented programming in Python
- Creating loops
- Reading and writing text files
- Capturing input at runtime
- Documenting your scripts
Skill Level Beginner
1. Python for ArcGIS Basics
2. Strings, Numbers, and Variables
Work with numeric values5m 22s
3. Syntax Rules
4. Manipulating Strings
5. Object-Oriented Programming
6. Using Loops
7. Generate Log Files
8. Input at Run Time
9. Help Documents
Documenting a script1m 59s
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.