-
Notifications
You must be signed in to change notification settings - Fork 78
Closed
Labels
Description
I may have asked this before but I searched high and low and cannot find the solution anymore. The examples show how to create a database and do things with it.
What is wrong here, I can print the self.db containing the database connection but I cannot use the properties method of it..
import sys
import logging
import configparser
from arango import ArangoClient
logging.basicConfig(
filename="test.log",
level=logging.DEBUG,
format = "%(asctime)s:%(levelname)s:%(message)s"
)
class dataBeest(object):
def __init__(self):
logging.debug("Initializing database object.")
self.initialize_db()
def read_db_config(self):
logging.debug("Reading database configuration.")
try:
# Return db config from config file
config = configparser.ConfigParser()
config.read('arango-client.conf')
return config['database']
except IOError as e:
print('Reading config failed: {}'.format(e))
except:
print('Unexpected error: {}'.format(sys.exc_info()[0]))
raise
def initialize_db(self):
logging.debug("Initializing database connection.")
try:
databaseConfig = self.read_db_config()
client = ArangoClient(
protocol=databaseConfig['protocol'],
host=databaseConfig['host'],
port=databaseConfig['port'],
username=databaseConfig['username'],
password=databaseConfig['password'],
enable_logging=databaseConfig['enable_logging']
)
self.db = client.database(databaseConfig['database'])
# print(self.db.properties())
self.collection = self.db.collection(databaseConfig['collection'])
logging.debug('Database: {}'.format(self.db))
logging.debug('Collection: {}'.format(self.collection))
except:
print('Unexpected error: {}'.format(sys.exc_info()[0]))
raise
testen = dataBeest()