Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Multi Select from SQL
#1
Hi Gurus,
I am planning to get multiple values from single select from Database and use it in the code further down as per the need of the project.
I am trying like this

FeedId[] = Select column1, column2, column3 from MyTable

Id=FeedId[0]
BatchId=FeedId[1]
MyLoc=Feedid[2]

but this is not working. could you please share how to get these multiple values get extracted.
Reply
#2
I'd suggest using SqlAlchemy, tutorial here: SQLAlchemy Tutorial
It is much easier to use once setup.
Reply
#3
Hi Larz,
I need in this format when we have a single record and do not need loop

Local_id = pd.read_sql_query('select ISNULL(max(Id),0)+1 from firstTable', conn)
Local_id
# =============================================================================
# Now Select One value from the DB to local variable
# and setting up few columns those are not from Data File
# =============================================================================
oLid=Local_id.loc[0]
oLid
Reply
#4
anyone?
Hi Experts. need your help
Reply
#5
Hi Experts,
can anyone help me here?
Reply
#6
(Oct-13-2020, 10:29 AM)tehzeebahmed Wrote: Local_id = pd.read_sql_query('select ISNULL(max(Id),0)+1 from firstTable', conn)
Local_id
# =============================================================================
# Now Select One value from the DB to local variable
# and setting up few columns those are not from Data File
# =============================================================================
oLid=Local_id.loc[0]
oLid
But what is your question? Does it work? Does it not give the right result? Do you get an error message? What does table "firstTAble" look like?
Reply
#7
Is the database really huge? What happened if you try to retrieve all elements, e.g. pd.read_sql_query('select * from your_db')... It is hard to answer questions dealing with external resources... How can we reproduce the problem?!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  SQL select join operation in python(Select.. join) pradeepkumarbe 1 2,205 Feb-14-2019, 08:34 PM
Last Post: woooee

Forum Jump:

User Panel Messages

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