Skip to content
This repository has been archived by the owner on Dec 18, 2021. It is now read-only.

python file not connecting #14

Open
gigname opened this issue Apr 21, 2019 · 2 comments
Open

python file not connecting #14

gigname opened this issue Apr 21, 2019 · 2 comments

Comments

@gigname
Copy link

gigname commented Apr 21, 2019

No description provided.

@gigname
Copy link
Author

gigname commented Apr 21, 2019

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)

@gigname
Copy link
Author

gigname commented Apr 21, 2019

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'])

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant