Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create daily bigquery and append to table #1

Open
guil-lambert opened this issue Dec 9, 2022 · 3 comments
Open

Create daily bigquery and append to table #1

guil-lambert opened this issue Dec 9, 2022 · 3 comments
Assignees

Comments

@guil-lambert
Copy link
Contributor

No description provided.

@guil-lambert guil-lambert self-assigned this Dec 9, 2022
@guil-lambert
Copy link
Contributor Author

I created a scheduled query that appends the last day's data to a table hosted here: arcane-world-371019.First_sync.1

Here's the full query string:

SELECT
  address,
  block_number,
  transaction_hash,
  block_timestamp,
  log_index,
  transaction_index,
  CONCAT('0x',(CAST(SUBSTRING(DATA, 3, 64) AS string))) AS amount0,
  CONCAT('0x',(CAST(SUBSTRING(DATA, 67, 64) AS string))) AS amount1,
  CONCAT('0x',(CAST(SUBSTRING(DATA, 131, 64) AS string))) AS sqrtPrice,
  CONCAT('0x',(CAST(SUBSTRING(DATA, 195, 64) AS string))) AS liquidity,
IF
  ((CAST(CONCAT('0x',(CAST(SUBSTRING(DATA, 317, 16) AS string))) AS int)) > CAST('0xf00000' AS int), (CAST(CONCAT('0x',(CAST(SUBSTRING(DATA, 317, 16) AS string))) AS int))- CAST('0xffffff' AS int), CAST(CONCAT('0x',(CAST(SUBSTRING(DATA, 317, 16) AS string))) AS int)) AS tick
FROM
  `bigquery-public-data.crypto_ethereum.logs`
WHERE
  DATA != ""
  AND transaction_hash != ""
  AND ARRAY_LENGTH(topics) != 0
  AND topics[
OFFSET
  (0)] = "0xc42079f94a6350d7e6235f29174924f928cc2ac818eb64fed8004e115fbcca67"
  AND (CAST(SUBSTRING(DATA, 259, 64) AS string)) != ''
  AND DATE(block_timestamp) >= "2021-05-01"
ORDER BY
  block_timestamp ASC,
  transaction_index

@guil-lambert
Copy link
Contributor Author

guil-lambert commented Dec 9, 2022

I am able to access the database using the following query:

pandas.read_gbq("SELECT * FROM `arcane-world-371019.First_sync.1` LIMIT 1000", "arcane-world-371019")

Juan can't:

hmmm I keep getting access denied (both with my gmail and panoptic accounts)
GenericGBQException: Reason: 403 POST https://bigquery.googleapis.com/bigquery/v2/projects/arcane-world-371019/jobs?prettyPrint=false: Access Denied: Project arcane-world-371019: User does not have bigquery.jobs.create permission in project arcane-world-371019.


Location: None
Job ID: 50bb0cfb-8ac4-4b82-b008-c90e8ce81897

I added him directly as a principal, we'll see if that fixes it.

@guil-lambert
Copy link
Contributor Author

Scheduled! Runs every day at 11:59pm UTC

Image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant