Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
2506 connectés 

  FORUM HardWare.fr
  Programmation
  Python

  PYTH COUNT MYSQL.Connector

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

PYTH COUNT MYSQL.Connector

n°2306108
erwan83
Du Shift DEL tu te méfieras !
Posté le 28-09-2017 à 10:10:10  profilanswer
 

Hello
Voila une bonne grosse méthode de bourrin (la mienne) pour trouver le nombre de lignes d'une table.
J'arrive pas à capter comment faire un count avec MYSQL.Connector
Quelqu'un peut-il me sortir un exemple simple ?
Merci beaucoup

Code :
  1. cursor1_1 = cnx_1.cursor(buffered=True)
  2. ligne = "SELECT has_title FROM base WHERE 1"
  3. try:
  4.     cursor1_1.execute(ligne)
  5.     for row in cursor1_1:
  6.         nbligne=nbligne+1
  7. except:
  8.     print "erreur"
  9. else:
  10.     print nbligne,"lignes"


---------------
https://www.oise-net-multiservices.com
mood
Publicité
Posté le 28-09-2017 à 10:10:10  profilanswer
 

n°2306260
masklinn
í dag viðrar vel til loftárása
Posté le 01-10-2017 à 14:01:38  profilanswer
 

Connais pas MYSQL.Connector, mais je présume que c'est compatible DBAPI 2.0, donc:

Code :
  1. with cnx_1.cursor() as cr:
  2.    cr.execute('SELECT count(*) FROM table')
  3.    count = cr.fetchone()


[:spamafote]


---------------
I mean, true, a cancer will probably destroy its host organism. But what about the cells whose mutations allow them to think outside the box by throwing away the limits imposed by overbearing genetic regulations? Isn't that a good thing?
n°2306265
erwan83
Du Shift DEL tu te méfieras !
Posté le 01-10-2017 à 20:31:11  profilanswer
 

Merci je vais essayer ça !!


---------------
https://www.oise-net-multiservices.com

Aller à :
Ajouter une réponse
  FORUM HardWare.fr
  Programmation
  Python

  PYTH COUNT MYSQL.Connector

 

Sujets relatifs
Problème workbooks.countSondage de satisfaction avec Mysql
[résolu]problème comparaison Php/MySqlServeur Mysql
[PERL/MySQL] Utilisation d'une variable dans la clause WhereId absolu et Id relatif dans la même table MySQL
Passer de MySQL à MySQLi pour PHP 7[MySQL] Aide conception d'une BDD
Comment réaliser un historique d'achat ? (PHP, MySQL)Recherche Plateforme Visuelle type Access pour MySQL/Web
Plus de sujets relatifs à : PYTH COUNT MYSQL.Connector


Copyright © 1997-2025 Groupe LDLC (Signaler un contenu illicite / Données personnelles)