person-local 0.0.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- person-local-0.0.2/PKG-INFO +13 -0
- person-local-0.0.2/README.md +43 -0
- person-local-0.0.2/person_local.egg-info/PKG-INFO +13 -0
- person-local-0.0.2/person_local.egg-info/SOURCES.txt +13 -0
- person-local-0.0.2/person_local.egg-info/dependency_links.txt +1 -0
- person-local-0.0.2/person_local.egg-info/top_level.txt +1 -0
- person-local-0.0.2/person_local_python_package/__init__.py +0 -0
- person-local-0.0.2/person_local_python_package/src/__init__.py +0 -0
- person-local-0.0.2/person_local_python_package/src/delete_person_table.py +12 -0
- person-local-0.0.2/person_local_python_package/src/insert_person_table.py +30 -0
- person-local-0.0.2/person_local_python_package/src/update_person_table.py +49 -0
- person-local-0.0.2/pyproject.toml +17 -0
- person-local-0.0.2/setup.cfg +4 -0
- person-local-0.0.2/setup.py +26 -0
- person-local-0.0.2/tests/test_person.py +82 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: person-local
|
|
3
|
+
Version: 0.0.2
|
|
4
|
+
Summary: PyPI Package for Circles person Local/Remote Python
|
|
5
|
+
Home-page: https://github.com/circles-zone/person-local-python-package
|
|
6
|
+
Author: Circles
|
|
7
|
+
Author-email: info@circles.life
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: License :: Other/Proprietary License
|
|
10
|
+
Classifier: Operating System :: OS Independent
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
|
|
13
|
+
This is a package for sharing common XXX function used in different repositories
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# python-package-template
|
|
2
|
+
To create local package and remote package layers (not to create GraphQL and REST-API layers)
|
|
3
|
+
|
|
4
|
+
# directory structure
|
|
5
|
+
Root directory should have only .github/, ,gitignore, README.md and the project directory (i.e. location_local_python_package same as repo) - This will allow is to easily switch to mono repo<br>
|
|
6
|
+
/location_local<br>
|
|
7
|
+
/location_local/get_country_name<br>
|
|
8
|
+
/location_local/get_country_name/src<br>
|
|
9
|
+
/location_local/get_country_name/src/get_country_name.py<br>
|
|
10
|
+
/location_local/get_country_name/tests<br>
|
|
11
|
+
/location_local/get_country_name/tests/test_get_country_name.py<br>
|
|
12
|
+
|
|
13
|
+
# database Python scripts in /db folder
|
|
14
|
+
Please place <table-name>.py in /db<br>
|
|
15
|
+
No need for seperate file for _ml table<br>
|
|
16
|
+
Please delete the example file if not needed<br>
|
|
17
|
+
|
|
18
|
+
# Create the files to create the database schema, tables, view and populate Meta Data and Test Date
|
|
19
|
+
/db/<table-name>.py - CREATE SCHEMA ... CREATE TABLE ... CREATE VIEW ...<br>
|
|
20
|
+
/db/<table-name>_insert.py to create records
|
|
21
|
+
|
|
22
|
+
# Update the setup.py (i.e.name, version)
|
|
23
|
+
|
|
24
|
+
# Please create test directory inside the directory of the project i.e. /<project-name>/tests
|
|
25
|
+
|
|
26
|
+
# Update the serverless.yml in the root directory
|
|
27
|
+
provider:
|
|
28
|
+
stage: play1
|
|
29
|
+
|
|
30
|
+
Update the endpoints in serverless.yml
|
|
31
|
+
|
|
32
|
+
# Working with VS Code
|
|
33
|
+
Please make sure you push to the repo launch.json fie that enables to run and debug the code<br>
|
|
34
|
+
|
|
35
|
+
# Unit-Test
|
|
36
|
+
We prefer using pytest and not unittest package<br>
|
|
37
|
+
|
|
38
|
+
Please create pytest.init in the project directory and not in the root directory
|
|
39
|
+
```
|
|
40
|
+
[pytest]
|
|
41
|
+
markers =
|
|
42
|
+
test: custom mark for tests
|
|
43
|
+
```
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: person-local
|
|
3
|
+
Version: 0.0.2
|
|
4
|
+
Summary: PyPI Package for Circles person Local/Remote Python
|
|
5
|
+
Home-page: https://github.com/circles-zone/person-local-python-package
|
|
6
|
+
Author: Circles
|
|
7
|
+
Author-email: info@circles.life
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: License :: Other/Proprietary License
|
|
10
|
+
Classifier: Operating System :: OS Independent
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
|
|
13
|
+
This is a package for sharing common XXX function used in different repositories
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
README.md
|
|
2
|
+
pyproject.toml
|
|
3
|
+
setup.py
|
|
4
|
+
person_local.egg-info/PKG-INFO
|
|
5
|
+
person_local.egg-info/SOURCES.txt
|
|
6
|
+
person_local.egg-info/dependency_links.txt
|
|
7
|
+
person_local.egg-info/top_level.txt
|
|
8
|
+
person_local_python_package/__init__.py
|
|
9
|
+
person_local_python_package/src/__init__.py
|
|
10
|
+
person_local_python_package/src/delete_person_table.py
|
|
11
|
+
person_local_python_package/src/insert_person_table.py
|
|
12
|
+
person_local_python_package/src/update_person_table.py
|
|
13
|
+
tests/test_person.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
person_local_python_package
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
from logger_local.LoggerLocal import logger_local
|
|
2
|
+
from circles_local_database_python import connection
|
|
3
|
+
|
|
4
|
+
logger_local.init(object = {"component_id":169 })
|
|
5
|
+
|
|
6
|
+
def delete_person(id):
|
|
7
|
+
conn = connection.Connection("person").connect()
|
|
8
|
+
db_cursor = connection.Connection.cursor(conn)
|
|
9
|
+
|
|
10
|
+
query = ("UPDATE person.person_table SET end_timestamp = CURRENT_TIMESTAMP WHERE id = {}".format(id))
|
|
11
|
+
db_cursor.execute(query)
|
|
12
|
+
conn.commit()
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
from logger_local.LoggerLocal import logger_local
|
|
2
|
+
from circles_local_database_python import connection
|
|
3
|
+
import mysql.connector
|
|
4
|
+
|
|
5
|
+
logger_local.init(object = {"component_id":169 })
|
|
6
|
+
|
|
7
|
+
def insert_person(person_id, number, gender_id, last_coordinate, location_id):
|
|
8
|
+
try:
|
|
9
|
+
conn = connection.Connection("person").connect()
|
|
10
|
+
db_cursor = connection.Connection.cursor(conn)
|
|
11
|
+
query = ("INSERT INTO person.person_table (id, number, gender_id, last_coordinate, location_id,start_timestamp) VALUES ({}, {}, {}, {}, {}, CURRENT_TIMESTAMP)".
|
|
12
|
+
format(person_id, number, gender_id, last_coordinate, location_id))
|
|
13
|
+
|
|
14
|
+
db_cursor.execute(query)
|
|
15
|
+
conn.commit()
|
|
16
|
+
print("Person inserted successfully.")
|
|
17
|
+
insert_person_ml(person_id,person_id)
|
|
18
|
+
except mysql.connector.Error as err:
|
|
19
|
+
print("Error:", err)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def insert_person_ml(id,person_id):
|
|
23
|
+
|
|
24
|
+
conn = connection.Connection("person").connect()
|
|
25
|
+
db_cursor = connection.Connection.cursor(conn)
|
|
26
|
+
|
|
27
|
+
query = ("INSERT INTO person.person_ml_table (id, person_id) VALUES ({},{})".format(id,person_id))
|
|
28
|
+
|
|
29
|
+
db_cursor.execute(query)
|
|
30
|
+
conn.commit()
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
from logger_local.LoggerLocal import logger_local
|
|
2
|
+
from circles_local_database_python import connection
|
|
3
|
+
|
|
4
|
+
logger_local.init(object = {"component_id":169 })
|
|
5
|
+
|
|
6
|
+
def conn_db(db,query):
|
|
7
|
+
conn = connection.Connection("person").connect()
|
|
8
|
+
db_cursor = connection.Connection.cursor(conn)
|
|
9
|
+
db_cursor.execute(query)
|
|
10
|
+
conn.commit()
|
|
11
|
+
|
|
12
|
+
def update_person_day(id,day):
|
|
13
|
+
query = ("UPDATE person.person_table SET day = {} WHERE id = {}".format(day,id))
|
|
14
|
+
conn_db("person",query)
|
|
15
|
+
|
|
16
|
+
def update_person_month(id,month):
|
|
17
|
+
query = ("UPDATE person.person_table SET month = {} WHERE id = {}".format(month,id))
|
|
18
|
+
conn_db("person",query)
|
|
19
|
+
|
|
20
|
+
def update_person_year(id,year):
|
|
21
|
+
query = ("UPDATE person.person_table SET year = {} WHERE id = {}".format(year,id))
|
|
22
|
+
conn_db("person",query)
|
|
23
|
+
|
|
24
|
+
def update_person_birthday_date(id,birthday_date):
|
|
25
|
+
query = ("UPDATE person.person_table SET birthday_date = '{}' WHERE id = {}".format(birthday_date,id))
|
|
26
|
+
conn_db("person",query)
|
|
27
|
+
|
|
28
|
+
def update_person_first_name(id,first_name):
|
|
29
|
+
query = ("UPDATE person.person_table SET first_name = '{}' WHERE id = {}".format(first_name,id))
|
|
30
|
+
conn_db("person",query)
|
|
31
|
+
update_person_ml_first_name(id,first_name)
|
|
32
|
+
|
|
33
|
+
def update_person_ml_first_name(id,first_name):
|
|
34
|
+
query = ("UPDATE person.person_ml_table SET first_name = '{}' WHERE id = {}".format(first_name,id))
|
|
35
|
+
conn_db("person",query)
|
|
36
|
+
|
|
37
|
+
def update_person_nickname(id,nickname):
|
|
38
|
+
query = ("UPDATE person.person_table SET nickname = '{}' WHERE id = {}".format(nickname,id))
|
|
39
|
+
conn_db("person",query)
|
|
40
|
+
|
|
41
|
+
def update_person_last_name(id,last_name):
|
|
42
|
+
query = ("UPDATE person.person_table SET last_name = '{}' WHERE id = {}".format(last_name,id))
|
|
43
|
+
conn_db("person",query)
|
|
44
|
+
update_person_ml_last_name(id,last_name)
|
|
45
|
+
|
|
46
|
+
def update_person_ml_last_name(id,last_name):
|
|
47
|
+
query = ("UPDATE person.person_ml_table SET last_name = '{}' WHERE id = {}".format(last_name,id))
|
|
48
|
+
conn_db("person",query)
|
|
49
|
+
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# This file should be in the future instead of setup.py
|
|
2
|
+
# https://python-poetry.org/docs/pyproject
|
|
3
|
+
|
|
4
|
+
[build-system]
|
|
5
|
+
requires = ["setuptools>=61.0"]
|
|
6
|
+
build-backend = "setuptools.build_meta"
|
|
7
|
+
|
|
8
|
+
[tool.poetry]
|
|
9
|
+
# TODO: Please update the name, similar to storage-local (suffix -local)
|
|
10
|
+
name = "person-local-python-package"
|
|
11
|
+
# I believe we are still using the version from setup.py and not from here until potery will work
|
|
12
|
+
version = "0.0.1" # https://pypi.org/project/<project-name> i.e. https://pypi.org/project/storage-local/
|
|
13
|
+
description = "person-local Python Package"
|
|
14
|
+
readme = "README.md"
|
|
15
|
+
authors = [
|
|
16
|
+
"Circlez.ai <info@circlez.ai>",
|
|
17
|
+
]
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import setuptools
|
|
2
|
+
# Each Python project should have pyproject.toml or setup.py
|
|
3
|
+
# TODO: Please create pyproject.toml instead of setup.py (delete the setup.py)
|
|
4
|
+
# used by python -m build
|
|
5
|
+
# ```python -m build``` needs pyproject.toml or setup.py
|
|
6
|
+
# The need for setup.py is changing as of poetry 1.1.0 (including current pre-release) as we have moved away from needing to generate a setup.py file to enable editable installs - We might able to delete this file in the near future
|
|
7
|
+
setuptools.setup(
|
|
8
|
+
# TODO: Please update the name and delete this line i.e. XXX-local or XXX-remote (without the -python-package suffix). Only lower case
|
|
9
|
+
name='person-local',
|
|
10
|
+
# TODO: Please update the URL bellow
|
|
11
|
+
version='0.0.2', # https://pypi.org/project/<project-name>/
|
|
12
|
+
author="Circles",
|
|
13
|
+
author_email="info@circles.life",
|
|
14
|
+
# TODO: Please update the description and delete this line
|
|
15
|
+
description="PyPI Package for Circles person Local/Remote Python",
|
|
16
|
+
# TODO: Please update the long description and delete this line
|
|
17
|
+
long_description="This is a package for sharing common XXX function used in different repositories",
|
|
18
|
+
long_description_content_type="text/markdown",
|
|
19
|
+
url="https://github.com/circles-zone/person-local-python-package",
|
|
20
|
+
packages=setuptools.find_packages(),
|
|
21
|
+
classifiers=[
|
|
22
|
+
"Programming Language :: Python :: 3",
|
|
23
|
+
"License :: Other/Proprietary License",
|
|
24
|
+
"Operating System :: OS Independent",
|
|
25
|
+
],
|
|
26
|
+
)
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import sys
|
|
2
|
+
import os
|
|
3
|
+
import datetime
|
|
4
|
+
from dotenv import load_dotenv
|
|
5
|
+
script_directory = os.path.dirname(os.path.abspath(__file__))
|
|
6
|
+
sys.path.append(os.path.join(script_directory,'..'))
|
|
7
|
+
from logger_local.LoggerLocal import logger_local
|
|
8
|
+
from circles_local_database_python import connection
|
|
9
|
+
from person_local_python_package.src.delete_person_table import delete_person
|
|
10
|
+
from person_local_python_package.src.update_person_table import (update_person_birthday_date,
|
|
11
|
+
update_person_first_name,
|
|
12
|
+
update_person_nickname,
|
|
13
|
+
update_person_last_name,
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
import pytest
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
load_dotenv()
|
|
21
|
+
logger_local.init(object = {"component_id":169 })
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
@pytest.mark.test
|
|
25
|
+
def test_update_person_birthday_date():
|
|
26
|
+
update_person_birthday_date(2,"2008-08-31")
|
|
27
|
+
conn = connection.Connection("person").connect()
|
|
28
|
+
db_cursor = connection.Connection.cursor(conn)
|
|
29
|
+
query = ("SELECT birthday_date FROM person.person_table WHERE id = {}".format(2))
|
|
30
|
+
db_cursor.execute(query)
|
|
31
|
+
result = db_cursor.fetchone()
|
|
32
|
+
db_cursor.close()
|
|
33
|
+
conn.close()
|
|
34
|
+
assert result[0] == datetime.date(2008, 8, 31)
|
|
35
|
+
|
|
36
|
+
@pytest.mark.test
|
|
37
|
+
def test_update_person_first_name():
|
|
38
|
+
update_person_first_name(22,"Tal")
|
|
39
|
+
conn = connection.Connection("person").connect()
|
|
40
|
+
db_cursor = connection.Connection.cursor(conn)
|
|
41
|
+
query = ("SELECT first_name FROM person.person_table WHERE id = {}".format(22))
|
|
42
|
+
db_cursor.execute(query)
|
|
43
|
+
result = db_cursor.fetchone()
|
|
44
|
+
db_cursor.close()
|
|
45
|
+
conn.close()
|
|
46
|
+
assert result[0] == "Tal"
|
|
47
|
+
|
|
48
|
+
@pytest.mark.test
|
|
49
|
+
def test_update_person_first_name():
|
|
50
|
+
conn = connection.Connection("person").connect()
|
|
51
|
+
db_cursor = connection.Connection.cursor(conn)
|
|
52
|
+
query = ("SELECT first_name FROM person.person_table WHERE id = {}".format(22))
|
|
53
|
+
db_cursor.execute(query)
|
|
54
|
+
result = db_cursor.fetchone()
|
|
55
|
+
db_cursor.close()
|
|
56
|
+
conn.close()
|
|
57
|
+
assert result[0] == "Evgeni"
|
|
58
|
+
|
|
59
|
+
@pytest.mark.test
|
|
60
|
+
def test_update_person_nickname():
|
|
61
|
+
update_person_nickname(2,"Batata")
|
|
62
|
+
conn = connection.Connection("person").connect()
|
|
63
|
+
db_cursor = connection.Connection.cursor(conn)
|
|
64
|
+
query = ("SELECT nickname FROM person.person_table WHERE id = {}".format(2))
|
|
65
|
+
db_cursor.execute(query)
|
|
66
|
+
result = db_cursor.fetchone()
|
|
67
|
+
db_cursor.close()
|
|
68
|
+
conn.close()
|
|
69
|
+
assert result[0] == "Batata"
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
@pytest.mark.test
|
|
73
|
+
def test_update_person_last_name():
|
|
74
|
+
update_person_last_name(22,"Blala")
|
|
75
|
+
conn = connection.Connection("person").connect()
|
|
76
|
+
db_cursor = connection.Connection.cursor(conn)
|
|
77
|
+
query = ("SELECT last_name FROM person.person_table WHERE id = {}".format(22))
|
|
78
|
+
db_cursor.execute(query)
|
|
79
|
+
result = db_cursor.fetchone()
|
|
80
|
+
db_cursor.close()
|
|
81
|
+
conn.close()
|
|
82
|
+
assert result[0] == "Blala"
|