Python Forum
Sequential number for rows retrieved and storing the Primary UKey to the line number
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Sequential number for rows retrieved and storing the Primary UKey to the line number
#1
Hi Forum,

My first post and also very new to Python. I need some help, please!

At the moment, when I retrieve the data from my table, it displays as below.

-------- -------- -------- --------- --
JOHN SMITH K8AC DEFAULT
DAVID SMITH C2TT DEFAULT
KEVIN HART AC2D ADMIN
JASON STATHAM T13T SUPERUSER
-------- -------- -------- --------- --

I am hoping to assign a line number to each row and at the same time stores the Primary UKey value to the line number, something like below

-------- -------- -------- --------- --
L1 JOHN SMITH K8AC DEFAULT
L2 DAVID SMITH C2TT DEFAULT
L3 KEVIN HART AC2D ADMIN
L4 JASON STATHAM T13T SUPERUSER
-------- -------- -------- --------- --

So that on the subsequent coding, I can simply retrieve the line number and edit that record rather than having to type the UKey value to identify the record I want to edit or delete. Thank you for the help!
Reply
#2
What have you tried? How is the data stored. You will need to show your code for getting help.
I welcome all feedback.
The only dumb question, is one that doesn't get asked.
My Github
How to post code using bbtags


Reply
#3
(Aug-22-2023, 10:01 AM)menator01 Wrote: What have you tried? How is the data stored. You will need to show your code for getting help.

Thank you. Currently, data is stored in the Postgres database

elif usermenuoption == 3:
cur = conn.cursor()
cur.execute("SELECT * FROM python_test")
records = cur.fetchall()
print(tabulate(records))
print("\nALL RECORDS DISPLAYED.")
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Brick Number stored as text with openpyxl CAD79 2 457 Apr-17-2024, 10:17 AM
Last Post: CAD79
  Reading and storing a line of output from pexpect child eagerissac 1 4,282 Feb-20-2024, 05:51 AM
Last Post: ayoshittu
  [SOLVED] Pad strings to always get three-digit number? Winfried 2 365 Jan-27-2024, 05:23 PM
Last Post: Winfried
  Prime number detector Mark17 5 818 Nov-27-2023, 12:53 PM
Last Post: deanhystad
  Create X Number of Variables and Assign Data RockBlok 8 977 Nov-14-2023, 08:46 AM
Last Post: perfringo
  find the sum of a series of values that equal a number ancorte 1 509 Oct-30-2023, 05:41 AM
Last Post: Gribouillis
  capturing multiline output for number of parameters jss 3 827 Sep-01-2023, 05:42 PM
Last Post: jss
  python sqlite autoincrement in primary column janeik 6 1,164 Aug-13-2023, 11:22 AM
Last Post: janeik
  doubling a number Skaperen 8 1,250 Jul-25-2023, 10:20 PM
Last Post: Skaperen
Question Extracting Version Number from a String britesc 2 1,105 May-31-2023, 10:20 AM
Last Post: britesc

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020