# 服务端开启服务:python queryserver.py start
import phoenixdb
import phoenixdb.cursor
url = 'http://node1:8765/'
conn = phoenixdb.connect(url, autocommit=True)
cursor = conn.cursor()
# cursor.execute("CREATE TABLE users (id INTEGER PRIMARY KEY, username VARCHAR)")
# cursor.execute("UPSERT INTO users VALUES (?,?)", (1, 'admin'))
cursor.execute("select * from users")
rows = cursor.fetchall()
print(rows[0])
cursor = conn.cursor(cursor_factory=phoenixdb.cursor.DictCursor)
cursor.execute("select * from users where id=1")
row = cursor.fetchone()
print(row)
print(row['USERNAME']) # 不能这样print(row.USERNAME)
cursor.close()
conn.close()