Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Tutorial at
Data at
Key Points:
- requires: sqlalchemy, psycopg2
- Setting up new database and user
- Difference between sql, postgres, sqlite
- Sqlite and timezones
- Connecting to the DB and DSNs
- Postegres, templates, unicode issues
- Adding and retrieving data
- install postgres
from sqlalchemy import create_engine
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker
import urllib2
import csv
#engine = create_engine('postgresql://localhost/pyclass1', echo=True)
#Base = declarative_base()
#Session = sessionmaker(bind=engine)
#class TaxReturns(Base):
# __tablename__ = 'movies'
def add_stuff():
def get_stuff():
def get_csv():
Get csv from the file system and make a list/dictionary
... whatever makes sense
field_names = ["RecordNumber","Zipcode","ZipCodeType","City","State","LocationType","Lat","Long","Xaxis","Yaxis","Zaxis","WorldRegion","Country","LocationText","Location","Decommisioned","TaxReturnsFiled","EstimatedPopulation","TotalWages","Notes"]
with open('pastie-5659260.txt', 'rb') as csvfile:
spamreader = csv.DictReader(csvfile, fieldnames=field_names, delimiter=',', quotechar='"')
import pdb; pdb.set_trace()
for row in spamreader.values():
if __name__ == '__main__':
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.