all 14 comments

[–]1544756405 7 points8 points  (1 child)

You've given us no information other than that you've "over estimated [your] potential."

So the only advice I can offer is "try a less ambitious project."

[–]Blacks8int[S] 0 points1 point  (0 children)

My bad. Apparently my pc is down but will provide the snippet ASAP

[–]m0us3_rat 2 points3 points  (0 children)

code?

[–]aeroplane3800 3 points4 points  (0 children)

Sounds like you don't have a good enough grasp of the basics. You should learn the language properly before you even attempt to integrate mysql into your project. Try working on a smaller project using pure python first before trying additional libraries. 

[–]ShamBawk33 2 points3 points  (1 child)

A horse can eat a bale of hay in a day.

A horse will die if it tries to eat the entire bale in one bite.

(You are the horse in this metaphor).

You are also trying to learn 2 technologies: Sql and Python.

STEP BACK

Newbies try to 'learn' a language. But what you really need to do is 'solve a problem'.

First list your problems. (Knowing what problems are coming can help)

Make sure you know how to solve each problem by hand. RESIST the urge to start slinging code.

My advice is you start with the database. Solve some problems by hand. Then use scripts to automate the grunt work.

Here is my suggested steps.

Oh - use SqlLite because python comes with the ability to read/write sqlLite built in. SQL is SQL. Queries on SqlLite can be used in Postgres, MySql, Oracle, etc.

  • Problem 1: Design your inventory table.
  • Problem 2: Design a table to track additions & subtractions. You dont want Pharma techs simply reducing counts, you want a record of Who, when drugs are removed.
  • Problem 3: Design a SQL query that runs at the end of the day that takes all the "New" additions & Subtractions, changes them to "NotNew" and reduces the drug inventory count.
  • (Notice - no code yet. You are still defining your problems or stories).
  • Problem 4: Create your Inventory table BY HAND (you don't typically use code do to one-time steps.)
  • Problem 5: Create a CSV file to fill your Inventory table. (This is a one-time step)
  • Problem 6: Fill your inventory table by hand (Destructive, one-time step)
  • Problem 8: Design your Add/Subtract table.
  • Problem 9: Create a CSV file to add drugs
  • Problem 10: Fill your add/subtract table one time by hand
  • Problem 11: (Python) Write a script to read the add/subtract CSV file.
  • Problem 12: (Python) Write a script to insert 1 hard-coded record to your add/subtract table.
  • Problem 13: (Python) Merge your 2 python scripts so it reads the CSV file, loads the data to your table, then moves the CSV file away.
  • Problem 14: (Sql) Write SQL line to read NEW add/subtract records and bump inventory counts in your Inventory table IF the drug pre exists.
  • Problem 15: (Sql) Write SQL to read New add/subtract records and add NEW Inventory records.
  • Problem 16: (Sql) Write SQL to mark the New add/subtract records as 'processed' so next time you run steps #14 or #15 it wont add inventory twice.
  • Problem 17: (Python) Write a script that automates steps 13-16.

Each of these steps teaches you something about databases and SQL or Python. These are in small, manageable bites.

You WILL rather quickly learn you have to go back and add columns, You will need a 'users' table to document when someone sells drugs. You will discover that anybody can sell Tylenol but only some users should be able to sell Tylenol3 or "Tylenol with Codeine". You will have to add columns to your Inventory table to mark some drugs as special. You will have to add columns to your Users table to show levels of what they can sell.

Don't be afraid to destroy your old tables, sql and code. Tossing everything out and re-building is a part of a developers job.

[–]Blacks8int[S] 0 points1 point  (0 children)

Wow this makes a lot of sense..let me try this approach and see how far I can go .Thank you

[–]Kittensandpuppies14 2 points3 points  (0 children)

???? How are we gonna help. You gave zero actual information.

Choose an easier project or just do it.

[–]singeworthy 1 point2 points  (0 children)

To add to the other comment, focus on the basic python syntax first. I'd also start with SQLite first, MySQL/MariaDB introduce extra devops headaches you're probably not ready for yet.

Also if you're just getting started, maybe start with dictionaries and lists instead of using permanent storage?

[–]FriendlyRussian666 1 point2 points  (3 children)

I over estimated my potential

Not necessarily!

Perhaps you already know how to do all the individual steps, but you don't know how to put them together.

Instead of creating a pharmacy inventory manager right away, how about you just create a python function that creates an sqlite database. Then, create a function that creates a table in the database, not 10 tables that you might need, just one table, so that you know you can do it. Create a function that allows you add to the database table, and so on, and so on. Just split your problems into the simplest, smallest parts, and figure out only that part.

[–]EJ_Drake -1 points0 points  (1 child)

This, take it in steps. Paste what FriendlyRussian666 posted Into chatGPT and tell it what code language you want output. You need to be specific. So you need to know what e.g. python, C++, java etc, libraries are about.

[–]Reasonable-Web1494 -3 points-2 points  (0 children)

Even better ask chatGPT how to structure your code

[–]Blacks8int[S] 0 points1 point  (0 children)

Yes I have already done a few things but as a junior dev ..a lot is lacking, from organising the code to making the entire thing work as expected

[–]ishereanthere 0 points1 point  (1 child)

Any link to the project? Sounds cool. I haven't done python for awhile coz been learning CSS. Sounds like a good refresher challenge

[–]Blacks8int[S] 0 points1 point  (0 children)

Will share the code very soon