Skip to content

Instantly share code, notes, and snippets.

@csabatini
Created December 10, 2017 01:35
Show Gist options
  • Save csabatini/392313c851ceebda31a04bd3d98b7c07 to your computer and use it in GitHub Desktop.
Save csabatini/392313c851ceebda31a04bd3d98b7c07 to your computer and use it in GitHub Desktop.
from sqlalchemy import *
engine = \
create_engine("postgresql://...@localhost:5432/nfldb")
metadata = MetaData(bind=engine)
teams = Table('team', metadata, autoload=True)
players = Table('player', metadata, autoload=True)
inputname = input('input a player name:')
conn = engine.connect()
s = select([players.c.player_id, players.c.first_name, players.c.last_name,
players.c.full_name]).where(players.c.full_name.ilike(inputname))
result = conn.execute(s)
print(result.fetchone())
print(type(players.c.player_id))
print(str(players.c.player_id))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment