Jan-15-2019, 09:52 AM
Hi,
Python: python2.7
OS : Centos7
I am posting this since ive grown desperate after getting daily headaches trying to implement SQL interaction into a current production script.
After creating several methods to be able to interact with sqlite3 in a smooth way i realized that this really should be turned into a class rather than a series of methods.
The problem is... i have never writen a new class before and writing this as my first class without external support is just silly.
So i need help with this since i can't find guides or documentations that makes it clear where to even start.
So far i have written methods for creating connection to a database, creating a new database(with preset default tables), getting data from the database, editing data in the database. So far i have verified that connecting to and creating new database methods work as intended, i have not yet tested getting or setting any data.
Since the scripts that will use these methods to interact with databases are long and bit too much to explain in short terms i wont go into any details. But the arguments i will use when interacting with database is 'database-name', 'column' and 'row-index'.
I know i just left out table. The reason is that in the beginning of this scripts of methods for database interaction i have stated lists which summed up is (
Table1 = ['column_A','column_B','column_C']
Table2 = ['column_AB','column_BB','column_CB']
)
So basicly i only need to point at which column i want to interact with and the script will check which table the specified column is in and target said table.
So the more i work on this script the more i understand that it would be best to create a class out of it, but again i have no idea where to start.
My best guess is to have the arguments db-name, row-index and column and to create classmethods for create, get and set (including submethods as connect to db) and additional classmethods for checking which table the column specified is in.
I do apologize if it is vague or unclear what im trying to achieve, please point at what is unclear and i will do my best to clarify. I am fairly new to python and programming in general and im self-taught so there is most likely huge gaps in my knowledge on some basics.
I do understand that this is alot to ask, but i am in over my head and there is no time or room for me to get more educated before going at it again. The alternative is to write some poor inefficient script which i really hate doing. I want to make a structured efficient solution from start, no placeholders :P.
In any case, thank you for having the patience for reading this far and again i do apologize if it is incoherent or just makes no sense.
Best regards,
Nuzvee
Python: python2.7
OS : Centos7
I am posting this since ive grown desperate after getting daily headaches trying to implement SQL interaction into a current production script.
After creating several methods to be able to interact with sqlite3 in a smooth way i realized that this really should be turned into a class rather than a series of methods.
The problem is... i have never writen a new class before and writing this as my first class without external support is just silly.
So i need help with this since i can't find guides or documentations that makes it clear where to even start.
So far i have written methods for creating connection to a database, creating a new database(with preset default tables), getting data from the database, editing data in the database. So far i have verified that connecting to and creating new database methods work as intended, i have not yet tested getting or setting any data.
Since the scripts that will use these methods to interact with databases are long and bit too much to explain in short terms i wont go into any details. But the arguments i will use when interacting with database is 'database-name', 'column' and 'row-index'.
I know i just left out table. The reason is that in the beginning of this scripts of methods for database interaction i have stated lists which summed up is (
Table1 = ['column_A','column_B','column_C']
Table2 = ['column_AB','column_BB','column_CB']
)
So basicly i only need to point at which column i want to interact with and the script will check which table the specified column is in and target said table.
So the more i work on this script the more i understand that it would be best to create a class out of it, but again i have no idea where to start.
My best guess is to have the arguments db-name, row-index and column and to create classmethods for create, get and set (including submethods as connect to db) and additional classmethods for checking which table the column specified is in.
I do apologize if it is vague or unclear what im trying to achieve, please point at what is unclear and i will do my best to clarify. I am fairly new to python and programming in general and im self-taught so there is most likely huge gaps in my knowledge on some basics.
I do understand that this is alot to ask, but i am in over my head and there is no time or room for me to get more educated before going at it again. The alternative is to write some poor inefficient script which i really hate doing. I want to make a structured efficient solution from start, no placeholders :P.
In any case, thank you for having the patience for reading this far and again i do apologize if it is incoherent or just makes no sense.
Best regards,
Nuzvee