-
Notifications
You must be signed in to change notification settings - Fork 1
Review dit #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Review dit #1
Conversation
| def put_pool_conn(self, conn): | ||
| return self.__pool.putconn(conn) | ||
|
|
||
| database_obj = Database() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ikii kayanee nek codingane koyo ngene setiap manggil file iki bakal deklarasi ulang mas.
Tapi jujur iki aku yo rareti bener opo ora mas. Soale nek bahasa lain biasane do nggo pointer
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Soalee biyen aku yo coba coba tapi durung nemu sg paling bener kepiye mas
|
|
||
|
|
||
| class Database: | ||
| def __init__(self, database: str = 'postgres', host: str = 'localhost', password: str = 'secret', user: str = 'root', port: str = '5432'): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Iki haram mas nek neng toped. Nek password dll di commit / dimasukke github
|
|
||
| def __create_connection(self): | ||
| try: | ||
| pool_connection = ThreadedConnectionPool( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Kenapaa milih ThreadedConnectionPool daripada SimpleConnectionPool mass? Cmiiw
| try: | ||
| cur = pool.cursor() | ||
| sql = """ | ||
| select * from tbl_job_desc limit 10 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ikii nek neng tutorial tutorial youtube / neng tempatku. Ojoo select * mass. Lebih baik select semua column di definisi satu" kaya
select column1, column2 dan seterusnyaa
| return cur.fetchall() | ||
| except Exception as error: | ||
| raise error | ||
| finally: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cursornyaa kalau error belum ditutup mass (cur)
| def get_pool_conn(self): | ||
| return self.__pool.getconn() | ||
|
|
||
| def put_pool_conn(self, conn): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
kalaau di init tadi kayanya pakai fitur generic di fungsi atas mas. Tapi kalau disini ndak pakai generic jadinya kurang konsisten mass
contoh generic itu yang ada tambahan kaya gini mas (self, text str)
| try: | ||
| cur = pool.cursor() | ||
| sql = """ | ||
| select * from tbl_job_desc where id = %s limit 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inii sql injection kayanya mas. Kalau gasalah kan biar ga kena sql injection paramnya dimasukin ke execute itu mas, atau udahh update baru yak modulnya mas? Cmiiw
No description provided.