Open gigname opened 5 years ago
import phoenixdb import phoenixdb.cursor
database_url = 'http://localhost:8765/' conn = phoenixdb.connect(database_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") print(cursor.fetchall())
cursor = conn.cursor(cursor_factory=phoenixdb.cursor.DictCursor) cursor.execute("SELECT * FROM users WHERE id=1") print(cursor.fetchone()['USERNAME'])
Traceback (most recent call last): File "/home/yoman/.local/lib/python3.6/site-packages/phoenixdb/avatica.py", line 156, in connect self.connection.connect() File "/usr/lib/python3.6/http/client.py", line 936, in connect (self.host,self.port), self.timeout, self.source_address) File "/usr/lib/python3.6/socket.py", line 724, in create_connection raise err File "/usr/lib/python3.6/socket.py", line 713, in create_connection sock.connect(sa) ConnectionRefusedError: [Errno 111] Connection refused
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "/home/yoman/Documents/projects/AnkitCables/phoenix.py", line 5, in
conn = phoenixdb.connect(database_url, autocommit=True)
File "/home/yoman/.local/lib/python3.6/site-packages/phoenixdb/init.py", line 66, in connect
client.connect()
File "/home/yoman/.local/lib/python3.6/site-packages/phoenixdb/avatica.py", line 158, in connect
raise errors.InterfaceError('Unable to connect to the specified service', e)
phoenixdb.errors.InterfaceError: ('Unable to connect to the specified service', ConnectionRefusedError(111, 'Connection refused'), None, None)