Python Forum
add database rows to dataframe
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
add database rows to dataframe
#7
I am not aquainted with SQL Server and neither with pandas. But are you sure you are using the right syntax? Should it not be:
pd.read_sql_query(SQL, conn, params=(userid, rolename))
And when everything fails you can always change the SQL string:
...
userid, rolename = row[['User Id', 'Role Name']]
SQL = f"select * from tablename where userid = '{userid}' and roleName = '{rolename}'"
sql_query = pd.read_sql_query(SQL, conn)
...
And don't forget, if anything happens you don't understand: insert print statements to see what the program really does.

Just saw your message. I think you have too many brackets ().
And post the error message if you have one. Don't take it personal but people seem to not realize the error is not just some text, it is designed to tell you exact why python cannot execute what you coded.
Note there is a button to post error messages.
Reply


Messages In This Thread
add database rows to dataframe - by cspower - Jan-23-2020, 06:37 PM
RE: add database rows to dataframe - by ibreeden - Jan-24-2020, 12:54 PM
RE: add database rows to dataframe - by cspower - Jan-24-2020, 09:55 PM
RE: add database rows to dataframe - by ibreeden - Jan-25-2020, 09:45 AM
RE: add database rows to dataframe - by cspower - Jan-27-2020, 02:48 PM
RE: add database rows to dataframe - by cspower - Jan-27-2020, 07:25 PM
RE: add database rows to dataframe - by ibreeden - Jan-27-2020, 07:27 PM
RE: add database rows to dataframe - by cspower - Jan-27-2020, 09:28 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Rows not adding to sqlite3 database using SQLAlchemy Calab 11 2,110 Jun-02-2023, 05:53 PM
Last Post: bowlofred
  Converting a json file to a dataframe with rows and columns eyavuz21 13 5,466 Jan-29-2023, 03:59 PM
Last Post: eyavuz21
  How to assign a value to pandas dataframe column rows based on a condition klllmmm 0 988 Sep-08-2022, 06:32 AM
Last Post: klllmmm
  The code I have written removes the desired number of rows, but wrong rows Jdesi1983 0 1,714 Dec-08-2021, 04:42 AM
Last Post: Jdesi1983
  Partial Matching Rows In Pandas DataFrame Query eddywinch82 1 2,500 Jul-08-2021, 06:32 PM
Last Post: eddywinch82
  Pandas DataFrame combine rows by column value, where Date Rows are NULL rhat398 0 2,214 May-04-2021, 10:51 PM
Last Post: rhat398
  Indexing [::-1] to Reverse ALL 2D Array Rows, ALL 3D, 4D Array Columns & Rows Python Jeremy7 8 7,610 Mar-02-2021, 01:54 AM
Last Post: Jeremy7
Question Dataframe Manipulation Coping Rows and Removing Dates ashleysnl 1 1,872 Feb-26-2021, 10:00 PM
Last Post: nilamo
  How to split dataframe object rows to columns Mekala 1 2,719 Nov-12-2020, 04:18 PM
Last Post: michael1789
  Adding loop results as rows in dataframe Shreya10o 2 2,330 May-09-2020, 11:00 AM
Last Post: Shreya10o

Forum Jump:

User Panel Messages

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