$attachment_id = 8; // attachment ID
$image_attributes = wp_get_attachment_image_src( $attachment_id ); // returns an array
Could you please specify which database table is referred for to retrieve the image source url?
Images (and all other attachments) are associated with a post in the posts
table. The attachment source URL is saved in the guid
column.
That’s not a good choice, because sooner or later GUIDs won’t follow the URL scheme anymore, so don’t query that field directly.