タグ

SQLに関するuokadaのブックマーク (44)

  • A step-by-step SQLAlchemy tutorial

    About This Tutorial This tutorial is for SQLAlchemy version 0.2. You may notice that some sections are marked "New in 0.2". If this is the first time you're reading this tutorial, you can safely skip those sections. On the other hand, if you read the previous version of this tutorial and are now trying to learn SQLAlchemy 0.2, then just search for the text "New in 0.2" and you'll have a lot less r

  • MySQL— SQLAlchemy 0.6.6 Documentation

    DBAPI Support¶ The following dialect/DBAPI options are available. Please refer to individual DBAPI sections for connect information. mysqlclient (maintained fork of MySQL-Python) PyMySQL MariaDB Connector/Python MySQL Connector/Python asyncmy aiomysql CyMySQL PyODBC Supported Versions and Features¶ SQLAlchemy supports MySQL starting with version 5.0.2 through modern releases, as well as all modern

    uokada
    uokada 2011/11/25
    mysql+pymysql://<username>:<password>@<host>/<dbname>[?<options>]
  • TokyoR#12でプレゼンをしてきました。

    前回のTokyo.R(3/5)からだいぶ日が経っていて、ちゃんとブログにまとめておかないとなーと思いながら、いろいろな理由を自分の中で付けて延ばし延ばしにしてしまっていました。 そんな折、先週金曜日に東北関東地震があって、いろいろ大変だったのですが、ちょっと落ち着いてきて、私にできることといったらこれぐらいしかないので、まとめてみました。 (地震には直接関係はありませんが…) RをSQLで操る過去に初めて使った言語が「SQL(Structured Query Language)」で長くそれ(しか)使っていなかったので、私の中でのプログラミングといえば、SQLでした。 で、昨年からRを使い始めたのですが、やっぱり集計がめんどくさい…。 Dataframeはテーブルに似ているのでapply系やaggregate系で集計するよりも、手慣れたSQLで集計したい!とRを触っていながら思っていました。

    uokada
    uokada 2011/04/29
    sqldf
  • limit/offsetについて考える - だるろぐ

    LIMIT 20 OFFSET (:page - 1) * 20 みたいなクエリは :page に大きい値が入れれるように設計されてるとクエリに殺されるので、 WHERE key = :offset_for_next_page LIMIT 20 なクエリになるよう設計してほしい。 http://twitter.com/kamipo/status/56304601049210880 俺もボスに教わるまで知らなかったのだが、 mysql> select id from mentions order by id asc limit 100, 10;がすることは、 データを10個だけfetchする ではなく、 110個データをfetchして、先頭から100個捨てる だ。何を今更って感じですよねー知ったのは10ヶ月ほど前でした。俺の未熟さを思い知れ。 で。このようにlimitを付けてデータを取得する

    limit/offsetについて考える - だるろぐ
    uokada
    uokada 2011/04/09
    ページングしたいならDBじゃなくて検索インデックス作るほうがいいね。