Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import mysql.connector
- #+--------------------------+
- #|Establish db connection |
- #+--------------------------+
- def open_db(hostname, dbname, uname, pswd):
- return mysql.connector.connect(
- host=hostname, user=uname, passwd=pswd, db=dbname,buffered=True
- )
- #+--------------------------+
- #|Returns player's location |
- #+--------------------------+
- def location(db):
- cur = db.cursor()
- cur.execute("select roomID from hahmo where c_ID = 1");
- return (cur.fetchone())[0]
- #+---------------------------------------+
- #|Returns the given places' descrioption |
- #+---------------------------------------+
- def kuvaus(db, id):
- cur = db.cursor()
- cur.execute("select KUVAUS from room where roomID = " + str(id))
- return (cur.fetchone())[0]
- #+---------------------------------------+
- #|Returns the list of possible routes |
- #+---------------------------------------+
- def directions(db, id):
- cur = db.cursor()
- cur.execute("select E, W, S, N, D, U from room where roomID = " + str(id))
- rivi = cur.fetchone()
- kompassi = ['E', 'W', 'S', 'N', 'D', 'U']
- directions = []
- for i in range(0, 4):
- if rivi[i] is not None:
- directions.append(kompassi[i])
- return directions
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement