• Activity
  • Votes
  • Comments
  • New
  • All activity
  • Showing only topics with the tag "comp". Back to normal view
    1. Dealing with databases, inserts, updates, etc. in Python

      Current Library: built in sqlite Current db: sqlite (but will have access to Snowflake soon for option 1 below) Wondering if anyone here has some advise or a good place to learn about dealing with...

      Current Library: built in sqlite
      Current db: sqlite (but will have access to Snowflake soon for option 1 below)

      Wondering if anyone here has some advise or a good place to learn about dealing with databases with Python. I know SQL fairly well for pulling data and simple updates, but running into potential performance issues the way I've been doing it. Here are 2 examples.

      1. Dealing with Pandas dataframes. I'm doing some reconciliation between a couple of different datasources. I do not have a primary key to work with. I have some very specific matching criteria to determine a match (5 columns specifically - customer, date, contract, product, quantity). The matching process is all built within Python. Is there a good way to do the database commits with updates/inserts en masse vs. line by line? I've looked into upsert (or inserts with clause to update with existing data), but pretty much all examples I've seen rely on primary keys (which I don't have since the data has 5 columns I'm matching on).

      2. Dealing with JSON files which have multiple layers of related data. My database is built in such a way that I have a table for header information, line level detail, then third level with specific references assigned to the line level detail. As with a lot of transactional type databases there can be multiple references per line, multiple lines per header. I'm currently looping through the JSON file starting with the header information to create the primary key, then going to the line level detail to create a primary key for the line, but also include the foreign key for the header and also with the reference data. Before inserting I'm doing a lookup to see if the data already exists and then updating if it does or inserting a new record if it doesn't. This works fine, but is slow taking several seconds for maybe 100 inserts in total. While not a big deal since it's for a low volume of sales. I'd rather learn best practice and do this properly with commits/transactions vs inserting an updating each record individually within the ability to rollback should an error occur.

      11 votes
    2. Group suggestion: tech support

      Right now ~comp and ~tech are getting these kinds of posts, but I personally feel a ~tech_support ~tech.support (or ~tech_help? ~tech.help) group would be a better alternative. People who love to...

      Right now ~comp and ~tech are getting these kinds of posts, but I personally feel a ~tech_support ~tech.support (or ~tech_help? ~tech.help) group would be a better alternative.

      People who love to help would flock to the group, and people who need it would feel safer to ask for help without receiving straight up LMGTFY (Let Me Google That For You) kind of answers.

      There could be also a ~help group, wich a much broader scope (probably about Tildes itself).

      What you think?

      14 votes