Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import psycopg2
- def main():
- conn_string = "host= '%s' port = '%s' dbname= '%s' user= '%s' password= '%s'" % (localhost, "8080", "livin_tokyo", "tokyo", "kyoto")
- conn = psycopg2.connect(conn_string)
- dict_cur = conn.cursor()
- sql = """SELECT id as num, name as irum, age, address as juso, salary as don
- FROM company
- ORDER BY id"""
- dict_cur.execute(sql)
- rows = dict_cur.fetchall()
- for row in rows:
- print("%s-year-old %s lives at %s and get paid %s every month" % (row[2], row[1], row[3], row[4]))
- if __name__ == "__main__":
- main()
Add Comment
Please, Sign In to add comment