Skip to content

Python Domain Specific Query Language - Final Project for CS 164

Notifications You must be signed in to change notification settings

ericdwang/PDSQL

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

56 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PDSQL (Python Domain Specific Query Language)

Final project for CS 164 at UC Berkeley, Fall 2014.

Deliverables:

Example Query

import sqlite3
from PDTable import PDTable

# Connect to the database
connection = sqlite3.connect('tests/db.sqlite3')
cursor = connection.cursor()
# Create a PDTable for the "counties" table
c = PDTable('counties', cursor=cursor)

# Get all the counties with a 2010 population greater than 2 million,
# get their statecodes, names, and 2010 populations,
# and show them in descending order by 2010 population
counties = reversed(
    c.where(c.population_2010 > 2000000)
     .select(c.statecode, c.name, c.population_2010)
     .order(c.population_2010))

# Print the compiled SQL statement
print(counties.compile())
# Print the actual results of running the query
print(counties)

About

Python Domain Specific Query Language - Final Project for CS 164

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages