generated from moevm/nsql-clean-tempate
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from moevm/hello_world
№1: Added hello world example
- Loading branch information
Showing
8 changed files
with
384 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Dockerfile | ||
|
||
FROM python:3.12-slim | ||
|
||
WORKDIR /app | ||
|
||
COPY pyproject.toml poetry.lock ./ | ||
|
||
RUN pip install poetry && poetry install --no-root | ||
Check failure on line 9 in hello_world/gighunt/Dockerfile GitHub Actions / Проверка наличия тега 0.8 и работоспособности docker-compose
|
||
|
||
COPY . . | ||
|
||
CMD ["poetry", "run", "python", "gighunt/app.py"] |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
version: '3.8' | ||
|
||
services: | ||
arangodb: | ||
image: arangodb:3.10 | ||
environment: | ||
- ARANGO_ROOT_PASSWORD=password | ||
ports: | ||
- "8529:8529" | ||
volumes: | ||
- arango_data:/var/lib/arangodb3 | ||
|
||
python-app: | ||
build: . | ||
depends_on: | ||
- arangodb | ||
environment: | ||
- ARANGO_HOST=arangodb | ||
- ARANGO_PORT=8529 | ||
volumes: | ||
- .:/app | ||
command: poetry run python gighunt/app.py | ||
|
||
volumes: | ||
arango_data: |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
from arango import ArangoClient | ||
|
||
|
||
def main(): | ||
# Подключаемся к ArangoDB | ||
client = ArangoClient(hosts='http://arangodb:8529') | ||
|
||
# Логинимся | ||
sys_db = client.db('_system', username='root', password='password') | ||
|
||
# Проверяем, существует ли база данных | ||
if not sys_db.has_database('test_db'): | ||
sys_db.create_database('test_db') | ||
|
||
# Подключаемся к базе данных | ||
db = client.db('test_db', username='root', password='password') | ||
|
||
# Проверяем, существует ли коллекция | ||
if not db.has_collection('test_collection'): | ||
collection = db.create_collection('test_collection') | ||
else: | ||
collection = db.collection('test_collection') | ||
|
||
# Вставляем данные | ||
doc = {'name': 'Alice', 'age': 25} | ||
collection.insert(doc) | ||
print('Document inserted:', doc) | ||
|
||
# Читаем данные | ||
cursor = collection.all() | ||
for document in cursor: | ||
print('Document found:', document) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
[tool.poetry] | ||
name = "gighunt" | ||
version = "0.1.0" | ||
description = "" | ||
authors = ["Fayzak <[email protected]>"] | ||
readme = "README.md" | ||
|
||
[tool.poetry.dependencies] | ||
python = "^3.10" | ||
python-arango = "^8.1.1" | ||
|
||
|
||
[build-system] | ||
requires = ["poetry-core"] | ||
build-backend = "poetry.core.masonry.api" |
Empty file.