Cloudron makes it easy to run web apps like WordPress, Nextcloud, GitLab on your server. Find out more or install now.


Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Bookmarks
  • Search
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo

Cloudron Forum

Apps | Demo | Docs | Install
  1. Cloudron Forum
  2. Kutt
  3. Best way to mass import links?

Best way to mass import links?

Scheduled Pinned Locked Moved Kutt
4 Posts 3 Posters 588 Views 3 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • ajtatumA Offline
    ajtatumA Offline
    ajtatum
    wrote on last edited by
    #1

    I have exported all my Bitly links and was curious what the best way to import ~2k records would be. There's an API call for creating one URL at a time... so I could loop through them with some pacing in between, but was curious if it's possible to access Kutt's database directly and import them that way... or if that's more trouble then it's worth.

    Any thoughts would be appreciated!

    martinkbsM girishG 2 Replies Last reply
    0
    • ajtatumA ajtatum

      I have exported all my Bitly links and was curious what the best way to import ~2k records would be. There's an API call for creating one URL at a time... so I could loop through them with some pacing in between, but was curious if it's possible to access Kutt's database directly and import them that way... or if that's more trouble then it's worth.

      Any thoughts would be appreciated!

      martinkbsM Offline
      martinkbsM Offline
      martinkbs
      wrote on last edited by
      #2

      Hi @ajtatum,

      For me the fastest way is to create a workflow in n8n that will loop through all the addresses in a list, and for each one of them, make an HTTP Request to create the shortened link in Kutt.

      😉

      1 Reply Last reply
      2
      • ajtatumA ajtatum

        I have exported all my Bitly links and was curious what the best way to import ~2k records would be. There's an API call for creating one URL at a time... so I could loop through them with some pacing in between, but was curious if it's possible to access Kutt's database directly and import them that way... or if that's more trouble then it's worth.

        Any thoughts would be appreciated!

        girishG Offline
        girishG Offline
        girish
        Staff
        wrote on last edited by
        #3

        @ajtatum From my quick testing, there is just a table called links. Might be easy to script this.

         id | address | description | banned | banned_by_id | domain_id | password | expire_in |       target        | user_id | visit_count |          created_at           |          updated_at           |                 uuid                 
        ----+---------+-------------+--------+--------------+-----------+----------+-----------+---------------------+---------+-------------+-------------------------------+-------------------------------+--------------------------------------
          1 | iL6uu0  |             | f      |              |           |          |           | https://cloudron.io |       2 |           0 | 2022-12-12 12:06:41.689773+00 | 2022-12-12 12:06:41.689773+00 | 65320acc-e34e-4341-8c35-2bdfd898c9d9
        
        1 Reply Last reply
        0
        • girishG Offline
          girishG Offline
          girish
          Staff
          wrote on last edited by
          #4

          Further....

          db81c034f66d9c4cc29c7811bb89b95f24=> \d links
                                                  Table "public.links"
              Column    |           Type           | Collation | Nullable |              Default              
          --------------+--------------------------+-----------+----------+-----------------------------------
           id           | integer                  |           | not null | nextval('links_id_seq'::regclass)
           address      | character varying(255)   |           | not null | 
           description  | character varying(255)   |           |          | 
           banned       | boolean                  |           | not null | false
           banned_by_id | integer                  |           |          | 
           domain_id    | integer                  |           |          | 
           password     | character varying(255)   |           |          | 
           expire_in    | timestamp with time zone |           |          | 
           target       | character varying(2040)  |           | not null | 
           user_id      | integer                  |           |          | 
           visit_count  | integer                  |           | not null | 0
           created_at   | timestamp with time zone |           | not null | CURRENT_TIMESTAMP
           updated_at   | timestamp with time zone |           | not null | CURRENT_TIMESTAMP
           uuid         | uuid                     |           | not null | uuid_generate_v4()
          Indexes:
              "links_pkey" PRIMARY KEY, btree (id)
          Foreign-key constraints:
              "links_banned_by_id_foreign" FOREIGN KEY (banned_by_id) REFERENCES users(id)
              "links_domain_id_foreign" FOREIGN KEY (domain_id) REFERENCES domains(id)
              "links_user_id_foreign" FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
          Referenced by:
              TABLE "visits" CONSTRAINT "visits_link_id_foreign" FOREIGN KEY (link_id) REFERENCES links(id) ON DELETE CASCADE
          

          So, then, I tried

          db81c034f66d9c4cc29c7811bb89b95f24=> INSERT INTO links (address, target, user_id) VALUES ('x1234', 'https://blog.cloudron.io', 2);
          INSERT 0 1
          

          Visiting x1234 redirects properly. So, quite easy to script this. Note that 2 is the user id, might have to check the db what the user id is in your case.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Bookmarks
          • Search