knox / Polars-readme-2.py
0 likes
0 forks
1 files
Last active
1 | >>> df = pl.scan_csv("docs/assets/data/iris.csv") |
2 | >>> ## OPTION 1 |
3 | >>> # run SQL queries on frame-level |
4 | >>> df.sql(""" |
5 | ... SELECT species, |
6 | ... AVG(sepal_length) AS avg_sepal_length |
7 | ... FROM self |
8 | ... GROUP BY species |
9 | ... """).collect() |
10 | shape: (3, 2) |
knox / Polars-readme-1.py
0 likes
0 forks
1 files
Last active
1 | >>> import polars as pl |
2 | >>> df = pl.DataFrame( |
3 | ... { |
4 | ... "A": [1, 2, 3, 4, 5], |
5 | ... "fruits": ["banana", "banana", "apple", "apple", "banana"], |
6 | ... "B": [5, 4, 3, 2, 1], |
7 | ... "cars": ["beetle", "audi", "beetle", "beetle", "beetle"], |
8 | ... } |
9 | ... ) |
knox / TypeORM-readme-48.ts
0 likes
0 forks
1 files
Last active
1 | const photos = await AppDataSource.getRepository(Photo) |
2 | .createQueryBuilder("photo") // first argument is an alias. Alias is what you are selecting - photos. You must specify it. |
3 | .innerJoinAndSelect("photo.metadata", "metadata") |
4 | .leftJoinAndSelect("photo.albums", "album") |
5 | .where("photo.isPublished = true") |
6 | .andWhere("(photo.name = :photoName OR photo.name = :bearName)") |
7 | .orderBy("photo.id", "DESC") |
8 | .skip(5) |
9 | .take(10) |
10 | .setParameters({ photoName: "My", bearName: "Mishka" }) |
knox / TypeORM-readme-47.ts
0 likes
0 forks
1 files
Last active
1 | { |
2 | id: 1, |
3 | name: "Me and Bears", |
4 | description: "I am near polar bears", |
5 | filename: "photo-with-bears.jpg", |
6 | albums: [{ |
7 | id: 1, |
8 | name: "Bears" |
9 | }, { |
10 | id: 2, |
knox / TypeORM-readme-46.ts
0 likes
0 forks
1 files
Last active
1 | import { AppDataSource } from "./index" |
2 | |
3 | // create a few albums |
4 | const album1 = new Album() |
5 | album1.name = "Bears" |
6 | await AppDataSource.manager.save(album1) |
7 | |
8 | const album2 = new Album() |
9 | album2.name = "Me" |
10 | await AppDataSource.manager.save(album2) |
knox / TypeORM-readme-45.ts
0 likes
0 forks
1 files
Last active
1 | const options: DataSourceOptions = { |
2 | // ... other options |
3 | entities: [Photo, PhotoMetadata, Author, Album], |
4 | } |
knox / TypeORM-readme-45.sh
0 likes
0 forks
1 files
Last active
1 | +-------------+--------------+----------------------------+ |
2 | | album_photos_photo_albums | |
3 | +-------------+--------------+----------------------------+ |
4 | | album_id | int(11) | PRIMARY KEY FOREIGN KEY | |
5 | | photo_id | int(11) | PRIMARY KEY FOREIGN KEY | |
6 | +-------------+--------------+----------------------------+ |
knox / TypeORM-readme-44.ts
0 likes
0 forks
1 files
Last active
1 | export class Photo { |
2 | // ... other columns |
3 | |
4 | @ManyToMany(() => Album, (album) => album.photos) |
5 | albums: Album[] |
6 | } |
knox / TypeORM-readme-43.sh
0 likes
0 forks
1 files
Last active
1 | import { |
2 | Entity, |
3 | PrimaryGeneratedColumn, |
4 | Column, |
5 | ManyToMany, |
6 | JoinTable, |
7 | } from "typeorm" |
8 | |
9 | @Entity() |
10 | export class Album { |
knox / TypeORM-readme-42.sh
0 likes
0 forks
1 files
Last active
1 | +-------------+--------------+----------------------------+ |
2 | | photo | |
3 | +-------------+--------------+----------------------------+ |
4 | | id | int(11) | PRIMARY KEY AUTO_INCREMENT | |
5 | | name | varchar(255) | | |
6 | | description | varchar(255) | | |
7 | | filename | varchar(255) | | |
8 | | isPublished | boolean | | |
9 | | authorId | int(11) | FOREIGN KEY | |
10 | +-------------+--------------+----------------------------+ |