import pymysql.cursors

# Conectando ao banco de dados
connection = pymysql.connect(host='', unix_socket='/tmp/mysql.sock',
                       user='', passwd='', db='')

try:
    with connection.cursor() as cursor:
        # Create a new record
        sql = "INSERT INTO tabela (col1, col2) VALUES ('var1', 'var2')"
        cursor.execute(sql)

    # connection is not autocommit by default. So you must commit to save
    # your changes.
    connection.commit()
finally:
    connection.close()

E para listar:

from __future__ import print_function

import pymysql

conn= pymysql.connect(host='', unix_socket='/tmp/mysql.sock',
                       user='', passwd='', db='')
cur = conn.cursor()

cur.execute("SELECT post_title, post_content FROM wp_posts LIMIT 0,10;")

print(cur.description)

print()

for row in cur:
    print(row)

cur.close()
conn.close()

import pymysql 
db = pymysql.connect(host='', unix_socket='/tmp/mysql.sock',
	            user='', passwd='', db='rafaelrjp20')
cur = db.cursor(pymysql.cursors.DictCursor)


sql = "SELECT url FROM tabela WHERE arquivo is null or imagem is null order by id desc limit 0,1;"
cur.execute(sql)
for row in cur:
    print(row['url'])
    info_single_page(row['url'])
Este artigo foi útil ?
SimNão

15 Replies to “Python conectando ao Mysql”

  1. 33wim disse:

    Alright, 33wim, let’s see what you’ve got! Hope the experience is smooth and the wins are plentiful. Wish me luck! Check them out here 33wim.

  2. Okay, 3pattiluckyapk is the real deal if you’re into teen patti. Downloaded the APK, and it runs smoothly. If you’re a fan, check it out 3pattiluckyapk.

  3. vsp777game disse:

    VSP777game! Classic vibes, man. Slots and stuff. Easy to get into, but be careful, it can be a time sink! Find it here vsp777game.

  4. 939betcomapp disse:

    Downloaded the 939betcomapp the other day. It’s actually pretty smooth. Navigation is easy, and placing bets is a breeze. I’d recommend giving it a shot if you’re into mobile betting. More details here: 939betcomapp

  5. 55666 bong88 disse:

    Alright, 55666 bong88 is the real deal. I’ve had some decent wins on this site. The interface is clean and easy to navigate, which is a major plus. Give it a shot! 55666 bong88

  6. bet20plays disse:

    Bet20plays – never heard of it, but I gave it a try. UI is good, easy to use. Games are okay, nothing groundbreaking though. Give it a whirl if you’re bored! Find it at: bet20plays

  7. 33win44 disse:

    Heard about 33win44 and checked it out on 33win44.net. Not bad, they have some cool promos running. Definitely worth checking out if you’re looking for something new. Jump on it 33win44

  8. Fabetafterlife on fabetafterlife.com is cool. Different kind of vibe than other sportsbooks. They got something going there. It’s your turn fabetafterlife

  9. Registering my account took less than a minute. It is great to see a platform that values the users time. Sign up at 32jililoginregisteronline today.

  10. idarushoki disse:

    This site has a great winning streak lately. I feel like my luck has improved since I switched to idarushoki. Keep it up!

  11. bt777app disse:

    The mobile app is a game changer. I can play anywhere without any glitches. It’s much more convenient than the browser version. Cheers to bt777app

  12. I really appreciate how easy the login process is here. No complicated steps just straightforward gaming. kkslot777login is definitely my new favorite.

  13. br52bet42 disse:

    Had a great run today! The customer support is also very responsive which gives me peace of mind. Try br52bet42

  14. f188game disse:

    The excitement on this site is next level! I had a great run last night and the customer support was super helpful. Give f188game a try for sure.

  15. bdke999 disse:

    I’ve tried a few platforms lately, but this one really stands out for its smooth interface. Definitely worth checking out if you want a hassle-free experience. Check it out at bdke999

Deixe um comentário

O seu endereço de e-mail não será publicado. Campos obrigatórios são marcados com *

Close Search Window
↑