A list of puns related to "Cursor (databases)"
I can see you can fetch multiple cols in MySQL using cursors but I also can see there are a lot steps to making and using cursors (explicit) so I am wondering what are the real scenarios where cursors are used?
If I click an item in a database, I just want to view the modal at first, not immediately jump into editing the title or another field.
I'm looking to code something where I wanna be able to hightlight some text in any window (or basically anywhere on my PC), retrieve it into a database, where I match it with another value and ultimately give an output of the matched value in the database.
For example I highlight the number 1 in a text, it goes into the database, finds the value 1, matches it with the value I decided, and creates an output of that value in a similar style to that. I've looked a bit into C# but I'm kind of a real noobie, so any advice on where to start and which language to use is greatly appreciated. Thanks!
Disclaimer: I posted this to StackOverflow last week and didn't receive any responses and to the cs50 subreddit and haven't received any responses. Googled all over and couldn't find an answer. Hoping someone here can concretely say "these are two different things that are just named the same"
When you query a database from Python using a library like psycopg2 and pyodbc you create a connection and then open a cursor with that connection.
pyodbc example
import pyodbc
myconnection = pyodbc.connect(<my connection info>)
mycursor = myconnection.cursor()
mycursor.execute('Select * From Sometable')
So in this case is the cursor just what is used to communicate with the database?
From the psycopg2 documentation
" class cursor
Allows Python code to execute PostgreSQL command in a database session. "
To me this is totally different than a cursor used in SQL Server Management Studio or PgAdmin4 which works on one row at a time. Can someone confirm that these are two completely different things that are just unfortunately named the same thing?
Why YSK: It gets annoying when you need to edit a typo and have to erase the whole word just to correct it. With this feature, you can precisely move the cursor around your typed content without having to gnash.
Edit: Bonus YSK:
β’ On Android, you can tap and swipe left from your backspace icon to delete whole words or sentences.
β’ You can tap and hold the caps lock icon and drag your thumb to any letter to quickly get an uppercase letter.
Scenario: My team is using GraphQL (apollo server without federation) as an API gateway. We started with a simple offset-based paging model Iβm interested in proposing that we adopt (or at least consider adopting) the Relay Cursor Connections Specification for maximum flexibility on the frontend.
Did some digging and sifting through the Apollo docs, Relay docs, as well as some other generic resources. By all accounts, due to infrequent changes and lack of need for infinite scroll, weβve decided that a simple βpageβ (or offset/limit) is straightforward enough.
However, for specification reasons, could it be worthwhile to expose the cursor spec at the API gateway layer, even if the cursor value only contains the next page (instead of an id/timestamp). Seems like a bit more effort but might pay off if it lets us change the underlying pagination scheme without breaking any frontend code
I created this blog database for my final project. I've completed every requirement for the project except one: creating a cursor.
I know how to write cursors, I know they are next to useless, and I can BS an impractical, unnecessary cursor in a heartbeat to get my points.
I'd much rather demonstrate a useful cursor example (in context to my blog structure) and actually learn something about practical cursor useage.
Can anyone think of a practical scenario?
Keep in mind: This database isn't bound to an application and I have to be able to execute it to prove it works.
Edit: I created a cursor using the advice of u/narayanis. I'd like to share it in case someone in a similar predicament stumbles into this post:
CREATE PROCEDURE MergeCategories
(
@OldCatOne as int,
@OldCatTwo as int,
@NewCatName as varchar(50),
@NewCatCleanName as varchar(50)
)
AS
DECLARE @NewCatID as int
SET @NewCatID = coalesce((select max(CATEGORY_ID) + 1 FROM CATEGORY), 1)
DECLARE @CatID as int
DECLARE @PostID as int
DECLARE merge_categories CURSOR FOR
SELECT CATEGORY_ID, POST_ID
FROM POST_CATEGORY
WHERE CATEGORY_ID = @OldCatOne
OR CATEGORY_ID = @OldCatTwo
OPEN merge_categories;
FETCH NEXT FROM merge_categories INTO @CatID, @PostID;
WHILE @@FETCH_STATUS=0
BEGIN
DELETE FROM POST_CATEGORY WHERE CATEGORY_ID = @CatID AND POST_ID = @PostID
INSERT INTO CATEGORY (CATEGORY_ID, CATEGORY, CATEGORY_CLEAN)
VALUES (@NewCatID, @NewCatName, @NewCatCleanName)
INSERT INTO POST_CATEGORY (CATEGORY_ID, POST_ID)
VALUES (10, @PostID)
FETCH NEXT FROM merge_categories INTO @CatID, @PostID;
END
CLOSE merge_categories
DEALLOCATE merge_categories
Say I do this:
import sqlite3
species = 'dog'
conn = sqlite3.connect('database.db')
cursor = conn.execute('SELECT * FROM cards where species like ?, (species, ))
k9s = []
for result in (cursor.fetchall()):
k9.append(result)
conn.close()
Can I then do something like this:
#Connection is still closed
print(k9s[3])
Thanks for reading.
As per title, my TW installation is doing this more and more as of late.
I would shutdown from my KDE session, and a blank screen with a blinking cursor would appear.
If I leave it alone for a while (a long while, like a few minutes!) it evenually shows the OEM screen with the tumbleweed logo underneath, and a few secs later it finally shuts down.
If I arrow up while the cursor is blinking, I get a tty for login.
Could someone kindly advise some troubleshooting steps?
journalctl -br -1
seems to stop at the session logout, and logout seems to happen in a snappy fashion (18:34:02 Activating service name='org.kde.LogoutPrompt' until 18:34:05 Reached target Exit the Session), so I suspect the hang is happening after, but I dunno which logs to check for that.
-- Journal begins at Fri 2021-12-10 13:44:40 CET, ends at Tue 2022-01-04 08:46:43 CET. --
gen 03 18:34:05 inspiron systemd[1771]: Reached target Exit the Session.
gen 03 18:34:05 inspiron systemd[1771]: Finished Exit the Session.
gen 03 18:34:05 inspiron systemd[1771]: Reached target Shutdown.
gen 03 18:34:05 inspiron systemd[1771]: app.slice: Consumed 11min 40.266s CPU time.
gen 03 18:34:05 inspiron systemd[1771]: Removed slice User Application Slice.
gen 03 18:34:05 inspiron systemd[1771]: Stopped Create User's Volatile Files and Directories.
gen 03 18:34:05 inspiron systemd[1771]: Closed PipeWire Multimedia System Socket.
gen 03 18:34:05 inspiron systemd[1771]: Closed PipeWire PulseAudio.
gen 03 18:34:05 inspiron systemd[1771]: Closed D-Bus User Message Bus Socket.
gen 03 18:34:05 inspiron systemd[1771]: Stopped Daily Cleanup of User's Temporary Directories.
gen 03 18:34:05 inspiron systemd[1771]: Stopped target Timers.
gen 03 18:34:05 inspiron systemd[1771]: Stopped target Sockets.
gen 03 18:34:05 inspiron systemd[1771]: Stopped target Paths.
gen 03 18:34:05 inspiron systemd[1771]: Stopped target Basic System.
gen 03 18:34:05 inspiron systemd[1771]: session.slice: Consumed 3min 10.982s CPU time.
gen 03 18:34:05 inspiron systemd[1771]: Removed slice User Core Session Slice.
gen 03 18:34:05 inspiron systemd[1771]: pipewire.service: Consumed 1min 9.002s CPU time.
gen 03 18:34:05 inspiron systemd[1771]: Stopped PipeWire Multimedia Service.
gen 03 18:34:05 inspiron systemd[1771]: Stopping PipeWire Multimedia Service...
gen 03 18:34:05 inspiron systemd[1771]: wireplumber.service: Consumed 2.670s CPU time.
gen 03 1
... keep reading on reddit β‘When using a DBAPI2 conformant library, you first have to connect to the database, then get a cursor for that connection. I understand the very basics of cursors. But what I am unsure about is when to create a new cursor. Should I make a new cursor for each query, make one per logical transaction or just simply have one cursor per application instance?
My gut tells me it's one of the first two...
Then there are SQLAlchemy sessions. Using SA, you get a "sessionmaker" which is basically a factory for sessions. This, to me, is a hint that you may want more than one session. But why? Should I go on the same feeling as I have for cursors/connections?
This is especially important to me for web-applications. I come from a PHP background, where essentially each requests "re-runs" the whole application. But a WSGI based app usually keeps running on the server. And if you have to deal with concurrent access, optimistic locking and all the related headaches, the questions about cursors and sessions becomes especially important.
Let's take Flask as an example. You can use before_request
and teardown_request
to create/close a session/cursor. But is this the correct way to do it? What if the user starts an operation which spans multiple HTTP requests and you want to do it in one transaction? What then?
It is a free app with no ads that makes it easier to use large smartphones with one hand by using a cursor controlled with one finger by swiping from edge of the screen.
It also has a PRO (2.49$ -> 0.99$ on sale) in-app purchase that offers more customizations and some extra features:
Play Store link: https://play.google.com/store/apps/details?id=com.quickcursor
The app was launched here on Reddit, and this is the third post about the app, so if you want to read more info about the journey, you can check this topics:
Thanks to everyone that helped me improve this app in the last two years with almost 100 updates, from first early access version 22 to current version 115.
You can check the changelog: image, XML, Text
The sale for PRO version (0.99$) will be available for 2 weeks starting from today: 17 - 31 January
The 100 free promo codes will be given here: 1 per account, just comment or send me a private message (not fake Reddit accounts without history or created in the last days). I will respond in chronological order, as fast as possible.
Please don't forget to Rate the app on Play Store.
... keep reading on reddit β‘I have several databases I've been asked to write some python programs for that have rather large datasets. One of the requests is the ability to dump a table into a CSV file. I can do this at a basic level but my understanding is that the cursor.execute() method is going to pull the entire resultset over into memory at once. I've seen the SScursor that MySQLdb supports but some of the libraries I'm having to use do not support that method or at least not obviously (using cx_oracle and JayDeBeAPI). Any ideas on how not to gobble up all my memory? Some of these tables are > 100 gb in size.
You know? The round circle in which you use to click on things in the menus. I only ask because it's definitely too slow and M&K can just zip across screens. I know it's easy for M&K because it ain't an analog stick and it's way easier to have such a flexible speed but I know I can handle a higher speed than what we have.
Edit: And Deadzone
Edit 2: Hot damn thanks for the rewards fellas.
I'm trying to create a quiz app with a database with two tables one for topics and one for the questions. The topicsID is a Foreign key in my questions table. I want to retrieve 2 random questions from each topicID there is 7 topics, so far I have only tried retrieving one topic but Idk how to retrieve the rest in the same function. I want to retrieve 2 random questions for each topic and put that in an array. IΒ΄m writing in Kotlin using sqlite.
val qList = ArrayList<MathQuestions>()
val db: SQLiteDatabase = this.readableDatabase
var sqlStatement = "SELECT * FROM $QuestionTableName WHERE $QTopicColumn_ID = '1' ORDER BY RAND() LIMIT 2"
val cursor: Cursor = db.rawQuery(sqlStatement, null)
When you query a database from Python using a library like psycopg2 and pyodbc you create a connection and then open a cursor with that connection.
pyodbc example
import pyodbc
myconnection = pyodbc.connect(<my connection info>)
mycursor = myconnection.cursor()
mycursor.execute('Select * From Sometable')
So in this case is the cursor just what is used to communicate with the database?
From the psycopg2 documentation
" class cursor
Allows Python code to execute PostgreSQL command in a database session. "
To me this is totally different than a cursor used in SQL Server Management Studio which works on one row at a time. Can someone confirm that these are two completely different things that are just unfortunately named the same thing?
Please note that this site uses cookies to personalise content and adverts, to provide social media features, and to analyse web traffic. Click here for more information.