Skip to content

stucka/fusionsql

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 

Repository files navigation

FusionSQL

A simple command line client for Google Fusion Tables

FusionSQL class can also be used within an application to query the Fusion Table databases

For commands see the documetation at Google

Code is available on github

Using FusionSQL

Here is an example of calling the FusionSQL class from your code:

from fusionsql.client import FusionSQL

fsql = FusionSQL()

result = fsql.query("SELECT ROWID, 'Police District'"
                    " FROM 224239 WHERE Neighborhood = ''")

 rows = [x for x in result]
 fails = []
 for row in rows:
     neighborhood_query = ("SELECT Neighborhood FROM 224239"
                           "WHERE Neighborhood not equal to '' "
                           "AND 'Police District' = '%s' LIMIT 1")
     print row
     try:
         neighborhood = fsql.query(
             neighborhood_query % row['Police District']).next()
         if neighborhood['Neighborhood']:
             fsql.query(
                 "UPDATE 224239 SET Neighborhood = '%s' WHERE ROWID = '%s'" %
                 (neighborhood['Neighborhood'].replace("'", "\'"),
                 row['rowid']))
             print 'Update: ' + row['rowid']
     except StopIteration:
         fsql.query(
             "DELETE FROM 224239 WHERE ROWID = '%s'" % row['rowid'])

About

Python client for Fusion Tables

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published