01: Initial commit with neo4j
This commit is contained in:
12
app/core/config.py
Normal file
12
app/core/config.py
Normal file
@@ -0,0 +1,12 @@
|
||||
from pydantic_settings import BaseSettings
|
||||
|
||||
class Settings(BaseSettings):
|
||||
|
||||
NEO4J_URI: str
|
||||
NEO4J_USER: str
|
||||
NEO4J_PASSWORD: str
|
||||
|
||||
class Config:
|
||||
env_file = ".env"
|
||||
|
||||
settings = Settings()
|
||||
43
app/core/logging_config.py
Normal file
43
app/core/logging_config.py
Normal file
@@ -0,0 +1,43 @@
|
||||
import logging
|
||||
from logging.config import dictConfig
|
||||
|
||||
|
||||
LOGGING_CONFIG = {
|
||||
"version": 1,
|
||||
"disable_existing_loggers": False,
|
||||
|
||||
"formatters": {
|
||||
"default": {
|
||||
"format": "[%(asctime)s] %(levelname)s | %(name)s | %(message)s",
|
||||
"datefmt": "%Y-%m-%d %H:%M:%S"
|
||||
},
|
||||
},
|
||||
|
||||
"handlers": {
|
||||
"console": {
|
||||
"class": "logging.StreamHandler",
|
||||
"formatter": "default",
|
||||
},
|
||||
},
|
||||
|
||||
"root": {
|
||||
"level": "INFO",
|
||||
"handlers": ["console"]
|
||||
},
|
||||
|
||||
"loggers": {
|
||||
"uvicorn.error": {
|
||||
"level": "INFO"
|
||||
},
|
||||
"uvicorn.access": {
|
||||
"level": "INFO"
|
||||
},
|
||||
"neo4j": {
|
||||
"level": "WARNING"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
def setup_logging():
|
||||
dictConfig(LOGGING_CONFIG)
|
||||
10
app/core/neo4j.py
Normal file
10
app/core/neo4j.py
Normal file
@@ -0,0 +1,10 @@
|
||||
from neo4j import GraphDatabase
|
||||
from app.core.config import settings
|
||||
|
||||
driver = GraphDatabase.driver(
|
||||
settings.NEO4J_URI,
|
||||
auth=(settings.NEO4J_USER, settings.NEO4J_PASSWORD)
|
||||
)
|
||||
|
||||
def get_driver():
|
||||
return driver
|
||||
Reference in New Issue
Block a user